Loops

    0

    0

    const numberOfPassengers = 10;
    
    // Do this X many times
    for (let i = 0; i < numberOfPassengers; i++) {
      console.log('Passenger boarded!');
    }
    
    // With arrays
    const passengers = [
        'Will Alexander',
        'Sarah Kate',
        'Audrey Simon'
    ]
    
    // for in
    for (let i in passengers) {
        console.log('Boarding passenger ' + passengers[i]);
    }
    
    // for of
    for (let p of passengers) {
      console.log('Boarding passenger ' + p);
    }
    
    // while
    while (passengers.length > 0) {
      passengersBoarded++;
      passengersUnboarded--;
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.