Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function printString(str){
printString("C");
}

//printAll();
printAll();


// You will notice that A, B, and C print in a different and random order each time you call printAll!
Expand Down
37 changes: 34 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,47 @@ const mashPotatoes = [
//Iteration 1 using callbacks -- Try to streamline with recursion
addFood(steak[0], '#steak', function(){
addFood(steak[1], '#steak', function(){
addFood(steak[2], '#steak', function(){
addFood(steak[3], '#steak', function(){
addFood(steak[4], '#steak', function(){
addFood(steak[5], '#steak', function(){
addFood(steak[6], '#steak', function(){
addFood(steak[7], '#steak', function(){

})
})
})
})
})
})
})
})


//Iteration 2 using then -- Try to streamline with recursion
// Iteration 2 using then -- Try to streamline with recursion
addFood(mashPotatoes[0], '#mashPotatoes').then(res => {
addFood(mashPotatoes[1], '#mashPotatoes').then(res => {

})
addFood(mashPotatoes[2], '#mashPotatoes').then(res => {
addFood(mashPotatoes[3], '#mashPotatoes').then(res => {
addFood(mashPotatoes[4], '#mashPotatoes').then(res => {
})
})
})
})
})

//Iteration 3

async function printAllWithAsync(){
await addFood(brusselSprouts[0], '#brusselSprouts');
await addFood(brusselSprouts[1], '#brusselSprouts');
await addFood(brusselSprouts[2], '#brusselSprouts');
await addFood(brusselSprouts[3], '#brusselSprouts');
await addFood(brusselSprouts[4], '#brusselSprouts');
await addFood(brusselSprouts[5], '#brusselSprouts');
await addFood(brusselSprouts[6], '#brusselSprouts');
await addFood(brusselSprouts[7], '#brusselSprouts');
await addFood(brusselSprouts[8], '#brusselSprouts');
}

printAllWithAsync();