0

I am not sure what exactly this question is asking for. Just feeling confused. Please help!

function isInteger(num) {

}

/* Do not modify code below this line */

console.log(isInteger(1), '<-- should be true');
console.log(isInteger(1.5), '<-- should be false');

when you console log you should get true for the whole number and false for the decimal.

Jaromanda X
  • 53,868
  • 5
  • 73
  • 87
  • you need to put code between `function isInteger(num) {` and `}` to satisfy the requirements .. an integer is a whole number, like `1` - a non-integer is a number with a non zero value after the decimal point, like `1.5` - true is `true` and false is `false` - these are the values you need to `return` – Jaromanda X Jul 14 '19 at 00:14
  • @JaromandaX function isInteger(num) { if (num === 1) { return 'true'; } return 'false'; } /* Do not modify code below this line */ console.log(isInteger(1), '<-- should be true'); console.log(isInteger(1.5), '<-- should be false'); – ApplePieStyle Jul 14 '19 at 00:25
  • still not working – ApplePieStyle Jul 14 '19 at 00:25
  • You could put this *after* the function right before the "Do not modify" bit: `isInteger = Number.isInteger` – Mark Jul 14 '19 at 00:40
  • `1` is the loneliest number, but it isn't the ONLY integer – Jaromanda X Jul 14 '19 at 00:48

1 Answers1

0

Look at How to check if a variable is an integer in JavaScript? to figure out the logic behind checking if the input is an integer. The simple function I create below returns true if the given number is an integer and false if not.

function isInteger(num) {
  if(num === parseInt(num, 10)){ // checks if input is integer
    return true;
  } else {
    return false;
  }
}

/* Do not modify code below this line */

console.log(isInteger(1), '<-- should be true');
console.log(isInteger(1.5), '<-- should be false');