Using of forEach in JavaScript(ES5)

 Using of forEach in JavaScript(ES5)

code:


var todos = [


    "clean room !", // todos[0]


    "brush teeth !", // todos[1]


    "exercise !",    // todos[2]


    "study jacascript",  // todos[3]


    "eat healthy!" // todos[4]


];




var todosImportant = [


    "clean room !", // todos[0]


    "brush teeth !", // todos[1]


    "exercise !",    // todos[2]


    "study jacascript",  // todos[3]


    "eat healthy!" // todos[4]


];


var todosLength = todos.length;


function logTodos(todos,i) {


    console.log(i,todos);


}




todos.forEach(logTodos);


todosImportant.forEach(logTodos);

Comments