Conclusion need help


#1

There was a problem with my syntax.

Replace this line with your code. 
<Below this line, add a link to the EXACT exercise that you are stuck at.>
var mySchedule =["work","play","study","eat"];
for (i=o;i<=length.mySchedule,i++){
    console.log("I"+mySchedule[i]+"everyday.");
}


#2

You have multiple errors. Here is your fixed code:

var mySchedule =["work","play","study","eat"];
for (i=0; i < mySchedule.length;i++){
    console.log("I " +  mySchedule[i] + " everyday.");
}

You had it like this:

var mySchedule =["work","play","study","eat"];
for (i=o;i<=length.mySchedule,i++){
    console.log("I"+mySchedule[i]+"everyday.");
}

So, starting from line 1 of your code, on line 2 you had 2 errors:

  • i = o => this wrong because you are using o instead of 0 for a counter here
  • i<=length.mySchedule,i++ => this is all written together so I will fix it together too. First, length.mySchedule is nothing. It should be mySchedule.length since length is a function you are calling on mySchedule. Second, you should use ; instead of , to separate for loop statements. And finally, it should be < instead of <= because you will get undefined value once your condition is equal to mySchedule.length because arrays goes 0...n-1, and if you go to n-th value it's undefined.

Overall, your fixed syntax is at top, but I would strongly suggest you review loops logic once more to make sure you understand it well.


#3

Thank you very much!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.