Skip to content

Instantly share code, notes, and snippets.

@Eth3rnit3
Created March 11, 2019 16:59
Show Gist options
  • Save Eth3rnit3/68ed2b30e9234da50661ed3aaa7f72b9 to your computer and use it in GitHub Desktop.
Save Eth3rnit3/68ed2b30e9234da50661ed3aaa7f72b9 to your computer and use it in GitHub Desktop.
///////////////////// Exercice 1 ///////////////////////
let num1 = 5;
let num2 = 4;
let i = 0;
let result = 0;
while(i < num1){
result = result + num2
i++;
}
///////////////////// Exercice 2 ///////////////////////
let tootalResult = 0;
for(let i = 0; i <= 100; i+=5){
console.log(i)
tootalResult += i
}
console.log(tootalResult)
///////////////////// Exercice 3 ///////////////////////
let num1 = 6;
let num2 = 0;
let operator = '/';
switch(operator){
case '-':
return console.log(num1 - num2);
case '+':
return console.log(num1 + num2);
case '*':
return console.log(num1 * num2);
case '/':
if(num1 === 0 || num2 === 0){
console.log("Division by zero is impossible !")
break;
}
return console.log(num1 / num2);
default:
return console.log('Operator is not valid !')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment