How to activate a prompt

Hello everyone! First post here. :blush: I am creating my first program using Js, and I’m stumped on figuring out an error prompt. Here is my code so far:

function hundyDivide() {
  let number = +prompt("Enter a number!", "");
  for (let i = 1; i <= 100; i++) {
    console.log(`${number} / ${i} = ${number / i}`);
  }
  if ("" === "") {
    return
    let number = +prompt("Hundy Says: \"I can only do magical things with numbers! Please enter a number!\"");
      for (let i = 1; i <= 100; i++) {
      console.log(`${number} / ${i} = ${number / i}`);
    }
}
  else {
  return number;
  }
}

hundyDivide();

I want the program to run so that if a user enters NaN or nothing at all, it returns a prompt asking the user for a number. When I run this code, it returns NaN / 1 = NaN…Nan / 100 = NaN.

Any advice would be greatly appreciated. Thanks!

What do you think this line is doing?

I have no idea. LOL. What I’m trying to say is if user inputs nothing or Nan, then activate the prompt asking for a number. I’ve tried playing around with it in several ways, including:

if(number === NaN)
if(number === Null)
if("" == "")

And so on.

JavaScript has a function called isNaN which would be useful here. Research it on Google.

1 Like

Thank you very much!