Your favorite music

Report a typo

You have an array of music genres:

const music = ["rock", "pop", "hip-hop", "electronic"];

Create a function myFavoriteMusic that uses the forEach method to display the text "My favorite music is {A} choosing from {B}" via the console.log for each element of the array. {A} is the current value of the element, {B} is the array itself.

Sample Input 1:

Sample Output 1:

My favorite music is rock choosing from rock,pop,hip-hop,electronic
My favorite music is pop choosing from rock,pop,hip-hop,electronic
My favorite music is hip-hop choosing from rock,pop,hip-hop,electronic
My favorite music is electronic choosing from rock,pop,hip-hop,electronic
Write a program in JavaScript
const music = ["rock", "pop", "hip-hop", "electronic"];

function myFavoriteMusic(music) {
// write your code
}
___

Create a free account to access the full topic