12 boucles et tableaux


What’s wrong with my syntax

    var noms = ["Giovanni", "Santos", "Daniel", "Anthony", "Manuel"];

    for (var i = 5; i < noms.length; i ++) {
        console.log ("Je connais quelqu'un appelé " noms[i]);


you set i to 5 and noms.length is 5 as well so the condition i < noms.length boils down to 5 < 5 which is false and therefore you skip the loop without even running it once. Better start counting from i = 0.

PS: And maybe delete the space between i and ++
PPS: And you need a + between the string ("Je connais quelqu'un appelé ") and the noms[i] entry to concatenate them to one large string.



var noms = [“Giovanni”, “Santos”, “Daniel”, “Anthony”, “Manuel”];

for (var i = 0; i < noms.length; i++); {
console.log (“Je connais quelqu’un appelé” + noms[i]);


for (var i = 0; i < noms.length; i++); {

Why did you add a semicolon between ) and {?
Just get rid of it:

the link is on conditions but the principle applies to loops as well.


when i introduce “+” she say he worked but not accepted my code,

for (var i = 0; i < noms.length; i++) {
console.log(“Je connais quelqu’un appelé” + noms[i]);

this is the answer but not work

Je connais quelqu’un appeléGiovanni
Je connais quelqu’un appeléSantos
Je connais quelqu’un appeléDaniel
Je connais quelqu’un appeléAnthony
Je connais quelqu’un appeléManuel


i found the problem thx for help me bro


Well in your original code you had it correct using a space at the end of your sentence:

"Je connais quelqu'un appelé "

instead of your new

"Je connais quelqu'un appelé"

so just add a plus in your original code:

"Je connais quelqu'un appelé " + noms[i]