Skip to content

Instantly share code, notes, and snippets.

@appoll
Last active May 26, 2021 17:50
Show Gist options
  • Save appoll/7e4d6fd6422ede5146c527b0de43aeba to your computer and use it in GitHub Desktop.
Save appoll/7e4d6fd6422ede5146c527b0de43aeba to your computer and use it in GitHub Desktop.
console.log("before the loop");
// I want to print all integer numbers from 0 to 50;
// for (i = 0; i <= 50; i++){
for (i = 0; i <= 50; i = i+1){
console.log(i);
if (i===10){
console.log("bingo!");
}
}
console.log("after the loop");
// E1. Print all even numbers between 10 and 20 (including 10 and 100). An even number is a number
// x for which the following is true: x % 2 === 0
// E2. Iterate from 0 to 50; Print "##" for even numbers and "!!" for odd numbers;
// E3. Print all numbers from 10 to 0 in descending order;
// E4. Calculate and print the sum of all even numbers in the interval 0, 100.
// E5. Make the code below work.
// readline-sync
inputFromUser = console.readInputFromUser();
while(isNaN(inputFromUser)){
console.log("This is not a number. Try again");
inputFromUser = console.readInputFromUser();
}
console.log("Thanks! You gave me a number!");
console.log(inputFromUser);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment