Created
June 15, 2022 03:56
-
-
Save natafaye/e0320c2e030404495aa786cf3e6de2df 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
/******** Arrays ********/ | |
let names = [ | |
"Abigail", | |
"Marco", | |
"Simone", | |
"Derek" | |
] | |
console.log(names); | |
let allNames = ""; | |
for(let i = 0; i < names.length; i++) { | |
let name = names[i]; | |
allNames += name + " " | |
console.log( name ); | |
} | |
names.push("Annapurna") | |
names.pop(); | |
names[1] = "Annapurna" | |
for(let name of names) { | |
if(name !== "Marco") { | |
allNames += name + " " | |
} | |
console.log( name ); | |
} | |
// allNames += names[2] + " " | |
console.log(allNames) | |
/******** Functions ********/ | |
function cookInOven(food, temperature) { // let food = 300; let temperature = "rice" | |
let cookedFood = food + " cooked at " + temperature; | |
return cookedFood; | |
} | |
let cookedRice = cookInOven("rice", 300); | |
console.log(cookedRice); | |
/******** Problem 1 From Last Week ********/ | |
// ask the user for a number to count to - prompt | |
let numberToCountTo = prompt("What number?") | |
numberToCountTo = parseInt(numberToCountTo) | |
// loop and say each number - for | |
for(let i = 0; i < numberToCountTo; i++) { | |
console.log(i + 1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment