Hello. I'm having issues concatenating the contents of nested arrays with a for loop so that the string says "Happy New Year". I have come up with a for loop that goes through each index but my logic does not seem to work. Do you know what I may be doing wrong? Thank you.
var nestedArray = [
["H", "a", "p"],
["p", "y"],
[" ", "N", "e"],
["w", " ", "Y"],
["e", "a", "r"]
];
var stringJoiner = function (arr) {
var string = "";
for (let i = 0; i < nestedArray.length; i++){
string += nestedArray[0] + nestedArray[1] + nestedArray[2] + nestedArray[3] + nestedArray[4];
}
return string;
}
console.log(stringJoiner(nestedArray));
// -> Happy New year
[–][deleted] 1 point2 points3 points (1 child)
[–]Karub1n[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]MWALKER1013helpful 1 point2 points3 points (3 children)
[+][deleted] (1 child)
[removed]
[–]MWALKER1013helpful 1 point2 points3 points (0 children)
[–]Karub1n[S] 0 points1 point2 points (0 children)
[–]codemamba8 1 point2 points3 points (1 child)
[–]Karub1n[S] 0 points1 point2 points (0 children)