Tell us what’s happening:
please i need explanation of my code and why it isn’t passing the test
Your code so far
function multiplyAll(arr) {
var product = 2;
// Only change code below this line
for (var i = 0; i< arr.length; i++){
for (var j = 0; j <arr[i].length; j++)
console.log( product * arr[i]);
}
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[5,1],[0.2,4,0.5],[3,9]]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36.
Sorry if it wasn’t clear, I was actually trying to explain based on your code.
function multiplyAll(arr) {
var product = 2;
// Only change code below this line
for (var i = 0; i< arr.length; i++){
for (var j = 0; j <arr[i].length; j++) //Issue 1 can be found here: you never opened your code block for this loop
console.log( product * arr[i]); //Issue 2 & 3 can be found here
}
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[5,1],[0.2,4,0.5],[3,9]]);
function multiplyAll(arr) {
var product = 2;
// Only change code below this line
for (var i = 0; i< arr.length; i++){
for (var j = 0; j <arr[i].length; j++){
console.log(arr[i][j]);
}
}
// Only change code above this line
return product;
}
// Modify values below to test your code
multiplyAll([[5,1],[0.2,4,0.5],[3,9]]);
function multiplyAll(arr) {
var product = 2; //So product is 2 at this point
// Only change code below this line
for (var i = 0; i< arr.length; i++){
for (var j = 0; j <arr[i].length; j++) {
console.log( product * arr[I][j]); //HINT: this line needs to be updated
}
}
// Only change code above this line
return product; //product is still 2 at this point - so at some point before this return statment is reached, you need to update the variable product. An assignment operator would look like product = something
}
// Modify values below to test your code
multiplyAll([[5,1],[0.2,4,0.5],[3,9]]);