New course! Every coder should learn Generative AI!
Try a free lesson0
Can someone please explain me why this happened?
HELLO I’M TRYING TO LEARN JAVASCRIPT AND THIS IS SIMPLE BUT I CAN’T UNDERSTAND WHY IN THIS FOR THE ARRAY DOES NOT START IN THE FIRST INDEX: let friends = [“John”, “Peter”, “Nancy”]; for(var I = 0; I<friends.length; I++){ document.getElementById(‘div’).innerHTML = amigos[I]; }
3 Answers
+ 2
if i'm right its only showing Nancy
to print them all
try using
+= amigod[I]
instead of
= amigos[I]
+ 2
Your array is named <friends>, but you try to access <amigos> which is undefined. I'm guessing you meant `friends[i]` instead of `amigos[i]` there.
0
man thank’s