Looping Examples

For Loop

let videogames = ["Skyrim", "Resident Evil", "Elden Ring", "Fallout", "Overwatch"]

        function forLoop(){
            for (let x = 0; x < videogames.length; x++)
                console.log(videogames[x])
        }

ForEach Method

let restaurants = ["Spork", "Sen", "Sosoba", "El Sancho", "Elevation"]

        function forEachMethod(){
            restaurants.forEach((restaurant, index) =>{
                console.log("Restaurant " + index + ": " + restaurant)
            })
        }

While Loop

let highered = ["OSU", "COCC", "UofO", "NAU", "ASU", "UofA"]

        function whileLoop(){
            let x = 0;
            while(x 
    

Do While Loop

let cats = ["Sphinx", "Tabby", "Maine Coon", "Ragdoll", "Turkish Angora"];

        function doWhileLoop() {
        let x = 0;
        do {
            console.log(cats[x]);
            x++;
        } while (x < cats.length);
        }

Map

let cake = ["Cheese", "Red Velvet", "German Chocolate", "Confetti", "Angelfood"];

        function mapLoop() {
            let newCakes = cake.map(function(cakeName) {
                return cakeName + " Cake";
            });
            console.log(newCakes);
        }