Ask coding questions

← Back to all posts
loop
BSlaven (4)

Can someone tell me why this prints ony once? It appears that the loop is useless/unnecessary.
https://repl.it/@BSlaven/Functions3
Thanks

Commentshotnewtop
ArchieMaclean (882)

You have made a very tiny error on line 3:

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

should be changed to this:

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

(removing the semicolon)

Please upvote if this helps :)

themaka (186)

@BSlaven The semi-colon ends the for loop and the console.log is treated like a separate instruction.