Tell us what’s happening:
Hello, I don’t want answers to the challenge. I’m having problems with the data entering the variable “a” in the for, when adding data to the array “a” I don’t understand why a string is entered, nor do I understand why there is an undefined before each block of arrays that is added. I tried the code in the pythontutor page, but it didn’t help me much.
I appreciate very much the help, sorry for the inconvenience.
Your code so far
function largestOfFour(arr) {
// You can do this!
let a = [];
let b = 0;
for (let i = 0; i < arr.length; i++) {
a[i] += arr[i];
}
console.log(a)
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
.
Challenge: Return Largest Numbers in Arrays
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/return-largest-numbers-in-arrays