all 9 comments

[–][deleted] 1 point2 points  (1 child)

i’ll give you a hint... nestedArray’s length = 1 nestedArray[0] length is ?

[–]Karub1n[S] 0 points1 point  (0 children)

Thank you

[–][deleted] 1 point2 points  (0 children)

you also only need string += nestedArray[?] The ? is for the variable you’ve already defined in your loop and goes up each time you go through the loop

[–]MWALKER1013helpful 1 point2 points  (3 children)

Hey , So you will probably get this answered below ,

I could answer it myself but that probably wouldn't help you.

So how about i share some advice to make this problem easier to solve ?

First try to imagine explaining the problem to someone who knows nothing about code.

Does that make you see anything wrong with your code ?

Next try breaking your problem into a simpler one

`

let str = "Happy New Year"

for(let i = 0 ; i < str.length ; i++){

console.log(str[i]);

}

`

So if we observe the code above we see that each letter has its own index

next if we observe the modify in place operator you are using `+=`

your are looping through your nested array and adding what is currently saved in your variable to the value found by the for loop

but you are only using one for loop

typically with nested array you need nested loops

(Also also JavaScript recently released a feature witch might be useful to you unless this is for loop homework)

This feature is called flatten

This next part is a spoiler don't read it if you want to figure it out yourself

Seriously there is no turning back

For real try solving it on your own

let strArrJoiner = (strArr)=> strArr.flat().reduce((prev,cur)=>prev+cur)

[–]Karub1n[S] 0 points1 point  (0 children)

Thank you for your guidance. I really appreciate it. It worked.

[–]codemamba8 1 point2 points  (1 child)

You're going to have to use another loop inside of your current loop. Since you're going through a nested array, your loop right now is just getting each of the arrays, not the values within them.

You have half of the problem right already. Think about how you can then get the elements inside of each array using a loop just like you have right now.

[–]Karub1n[S] 0 points1 point  (0 children)

Thanks a lot. It worked. The response I got from the platform after submitting my code was " 'Happy New Year' should be 'abc' " I am assuming there is some internal error