As part of my learning exercise, I am trying to create a function with a For loop. The function returns a new array variable merges and matches the index value of both array musicians and instruments.
So the expected return should be string:
"John Lennon Plays Guitar"
Here is my attempt, but I keep failing to get the return:
var musicians = ["John Lennon", "Paul McCartney", "George Harrison", "Ringo Starr"]
var instruments = ["Guitar", "Bass Guitar", "Lead Guitar", "Drums"]
function theBeatlesPlay(musicians, instruments) {
for (let i=0; i<musicians.length; i++) {
var newMusicians = musicians[i]
var newInstruments = instruments[i]
}
console.log(newMusicians[i] + "plays" + instruments[i])
}
console.logshould be inside theforloop