1var colors=["red","blue","green"];
2for (let i = 0; i < colors.length; i++) {
3 console.log(colors[i]);
4}
1let array = ['Item 1', 'Item 2', 'Item 3'];
2
3array.forEach(item => {
4 console.log(item); // Logs each 'Item #'
5});
1var person = {"name":"taylor","age":31};
2for (property in person) {
3 console.log(property,person[property]);
4}
5//name taylor
6//age 31
1var subjects = {
2 'math': 85,
3 'physics': 75,
4}
5
6for (var i in subjects) {
7 console.log(i + ' : ' + subjects[i]);
8}
9
10// math : 85
11// physics : 75