Skip to content

Commit

Permalink
Working while 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 da65354 commit 8e466c8
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion week-2/Homework/H-loops/exercise-1.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
/*
While Loops
---------------------------------
Exercise 1:
Using while loops complete the exercises to output the
correct results.
*/

//The 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

let j = 0;
while(j < 5) {

j++
}

// This while loop uses the variable loopLimit in its condition.
// Change the code below so it outputs "Goodbye" 5 times

let loopLimit = 2;
k = 0;
while(k < loopLimit) { //don't change this line
console.log("Goodbye");
k++
}


/*
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

0 comments on commit 8e466c8

Please sign in to comment.