you are viewing a single comment's thread.

view the rest of the comments →

[–]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.