Skip to content

Commit

Permalink
Add more While loop exercises
Browse files Browse the repository at this point in the history
Co-authored-by: Richard
  • Loading branch information
Aronja committed May 2, 2020
1 parent 1b05858 commit faac018
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
30 changes: 28 additions & 2 deletions week-2/Homework/H-loops/exercise-1.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,34 @@
/*
While Loops
WHILE LOOPS
---------------------------------
Exercise 1:
Using while loops complete the exercises to output the correct results.
*/
// This while loop outputs "Hello" 10 times. Change the code so it only outputs "Hello" 5 times
let i = 0;
while(i < 10){
console.log("Hello");
i++;
}
// This while loop doesn't do anything! Change the code so it outputs the sentence "Coding is easy" 3 times
i = 0;
while(i < 5){
i++;
}
// This while loop uses the variable loopLimit in its condition.
// Change the code below so it outputs "Goodbye" 5 times
let loopLimit = 2;
i = 0;
while(i < loopLimit){ // don't change this line!
console.log("Goodbye");
i++;
}


/*
Write a while loop that prints "eating 1 slice of pizza" 6 times to the console.
Use the variables slices and hungry to create a condition.
Expand Down
2 changes: 1 addition & 1 deletion week-2/Homework/H-loops/exercise-2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
For-Loops
FOR LOOPS
---------------------------------
Exercise 2-a:
---------------------------------
Expand Down

0 comments on commit faac018

Please sign in to comment.