dailyRoutine = ['eat','sleep','code'];
for (let x = 0; x < dailyRoutine.length; x++){
console.log(dailyRoutine[x]);
}
dailyRoutine = ['eat', 'sleep','code'];
for (const routine of dailyRoutine){
console.log(routine);
}
Note:
- The variable routine in for...of loop can be declared using var, let, or const
- for loop and for...of loop can be used for arrays as well as strings
- for(let x = array.length - 1; x >= 0; X--) can print in reverse order
- break and continue can control the looping
Top comments (0)