for and while

const todos = [
    { id: 1, text: 'Buy groceries', completed: false },
    { id: 2, text: 'Finish homework', completed: false },
    { id: 3, text: 'Cook dinner', completed: false },
    { id: 4, text: 'Wash car', completed: false },
];

console.log(todos.length);

//for
for (let i = 0; i < todos.length; i++) {
    console.log(`for ${i}`);
    console.log(`todos` + todos[i].id + ` - ` + todos[i].text)
}

//while
let x = 10
while (x < 14) {
    console.log(`loop ${x}`);
    x++;
}

  

posted @ 2025-07-11 17:04  华腾智算  阅读(11)  评论(0)    收藏  举报
https://damo.alibaba.com/ https://tianchi.aliyun.com/course?spm=5176.21206777.J_3941670930.5.87dc17c9BZNvLL