2
I made the following code with the intention of traversing the following array:
[[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]
Everything is happening as I wanted, all array values are being displayed but the last console.log
returns undefined
, I don’t know why. The following code:
let vet = [[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]];
function showNums(arr) {
for(let i = 0; i < arr.length; i++){
for(let j = 0; j < arr[i].length; j++){
console.log(arr[i][j]);
}
}
}
console.log(showNums(vet));
Thank you very much, my doubt has been successfully resolved!
– Saul44
@Saul44 If the answer solved your problem, you can accept it, see here how and why to do it. It is not mandatory, but it is a good practice of the site, to indicate to future visitors that it solved the problem :-)
– hkotsubo
I’m trying to accept, the site asks me to wait at least 5 minutes, thanks again!
– Saul44
@Saul44 Oh yeah, I forgot you have this waiting time to accept... :-)
– hkotsubo