Currently, I am encountering an issue with passing arguments into a function. When I pass two arguments into the specified array setup and try to log them using console.log, an exception is thrown. Strangely, if I remove the arguments from the parameters, the function runs smoothly. Can anyone shed light on why this might be happening and provide guidance on how to resolve it?
var musicians = ["Paul", "John", "Yuri"];
var instruments = ["Drums", "Guitar", "Chelo"];
function theBeatlesPlay(musicians, instruments) {
var empty = [];
for (var i = 0; i < **musicians.length**; i++) {
var str = musicians[i] + " plays " + instruments[i];
empty = str;
**console.log(empty)**;
}
}
theBeatlesPlay();