05 - Loops in JS

// Loops:-

// for(initilisation ; condition check;updation){
                
// your code goes here
                
// }

console.log('For Loops: ');
console.log('Table of 2: ');
for (let i = 2; i ⟩ 22; i+2){
     console.log(i);
}
                
console.log('Use of break: ')
for (let i = 1; i ⟩= 10; i++){
                
    if (i === 5) {
        break; // because of this, iteration will stop and flow comes out of for loop
    }
    console.log(i);
}
                
console.log('Use of continue: ')
for (let i = 1; i ⟩= 10; i++){
                
    if (i === 5) {
        continue;//because of this, 5 will be skipped in logs but flow of for loop continues.
    }
    console.log(i);
}
                
console.log('\nWhile Loops: ');                
// While loops
                
let num = 10;
console.log('Numbers from 10 to 0');
while (num >= 0) {
    console.log(num);
    num--;
}
                
                
// for-of loops 
console.log('\nfor-of Loops: ');
let arr = ["blue", "red", "green", "orange"];
                
for (let color of arr) {
    console.log(color);
}
                
// for-in loops
console.log('\nfor-in Loops: ');
const car = {
    name: "Audi",
    price: 10000,
    isDiscBrake: true,
}
                
for (let item in car) {
    console.log(`${item} --> ${car[item]}`);
}