Skip to content

Instantly share code, notes, and snippets.

@appoll
Created May 21, 2021 18:20
Show Gist options
  • Save appoll/c466a3d992442f419a1acfbeec1dbe40 to your computer and use it in GitHub Desktop.
Save appoll/c466a3d992442f419a1acfbeec1dbe40 to your computer and use it in GitHub Desktop.
readlineSync = require('readline-sync')
userName = readlineSync.question("What is your name?\n");
console.log(typeof userName);
age = readlineSync.question("What is your age?\n");
console.log("The type of age\n");
console.log(typeof age);
// Task 1:
// Add console statements below and check what values the test variables have.
// What about the types of these variables?
// anything funny?
// This will work
test1 = Number("234");
// This will be a NaN
test2 = Number("not a number hahaha");
// This will be a NaN
test3 = Number(null);
// This maybe is 1
test4 = Number(true);
// This maybe is 0
test4 = Number(false);
// Task 2 + - * /
// Modulo operator % - gives us back the rest of a division;
// Example: console.log(5 % 4) -> will print 1
E1.
// Write a program that gets as input a number from the User;
// Print "Odd" if the number is odd
// Print "Even" if the number is even
// Mathematical formula: a number is odd if the rest when dividing with 2 is 0
// Bonus: check if the user really inputs a number; if not, do nothing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment