0

i created fuction that do like a pow fuction and i used in Number.isInteger() for do not accept numbers that no integer, and the isInteger methods doesn't work. what the problem? thanks...

"use strict";

function pow(x, n) {
  let result = x;
  for (let i = 1; i < n; i++) {
    result *= x;
  }
  return result;
}

let x = prompt("x?", "")
let n = prompt("n?", "")

if (n < 2 || (Number.isInteger(n) === false)) {
  alert(`Power ${n} is not supported, use a positive integer`);
} else {
  alert(pow(x, n));
}
VLAZ
  • 26,331
  • 9
  • 49
  • 67

0 Answers0