Last active
May 10, 2021 23:48
-
-
Save natafaye/9583f157518827c4e653c2748094d734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fillBasket() { | |
emptyBasket(); | |
// Replace NUMBER_OF_TIMES with how many times you want your loop to loop | |
for(let i = 0; i < NUMBER_OF_TIMES; i++) { | |
// The code to run over and over again | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fillBasket() { | |
emptyBasket(); | |
for(let i = 0; i < numFish; i++) { | |
addItemToBasket("fish"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fillBasket() { | |
emptyBasket(); | |
// THE TWO FOR LOOPS WOULD BE HERE | |
// Replace ARRAY with some array that you want to loop over | |
// You can also rename your variable from item to something more descriptive | |
for(const item of ARRAY) { | |
// The code to run for each item in the array, saved in the variable item | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fillBasket() { | |
emptyBasket(); | |
// THE TWO FOR LOOPS WOULD BE HERE | |
for(const item of otherItems) { | |
addItemToBasket(item); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace ARRAY with some array that you want to loop over | |
// You can also rename your variable from item to something more descriptive | |
for(const item of ARRAY) { | |
// The code to run for each item in the array, saved in the variable item | |
} | |
// It might look something like this | |
let friendsAtDoor = ["Jose", "Emily", "Andre", "Simone"]; | |
for(const friend of friendsAtDoor) { | |
// The variable friend now holds whichever name we're currently working with | |
// The first time this loop runs, friend will equal "Jose" | |
// The second time friend = "Emily", etc | |
alert("Welcome " + friend + "!"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Replace NUMBER_OF_TIMES with how many times you want your loop to loop | |
for(let i = 0; i < NUMBER_OF_TIMES; i++) { | |
// The code to run over and over again | |
} | |
// You could put a number there | |
for(let i = 0; i < 5; i++) { | |
console.log("Let's do this 5 times!"); | |
} | |
// Or a variable that holds a number | |
let friendsAtDoor = 5; | |
for(let i = 0; i < friendsAtDoor; i++) { | |
alert("Welcome!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment