0

The automatic message a user gets when inputting an invalid response into a .questionInt('Type a number') when using node.js readline-sync module

'a'

Input valid number, please.

How do I change the response from 'Input valid number, please.' to 'This is not a number'?

here's part of the code:

  function numberOne() {
    firstNumber = readline.questionInt('Please enter the first number: ');
    if (isNaN(firstNumber)) {
      console.log('This is not a number');
      numberOne();
    }
  }

  function numberTwo() {
    secondNumber = readline.questionInt('Please enter the second number: ');
    if (isNaN(secondNumber)) {
      console.log('This is not a number');
      numberTwo();
    }
  }

I tried to remove the 'Int' from the question, and it worked, however, then the calculator wouldnt properly calculate the operations. 1+1=11. SO I think that means it just considered it a string. SHould I just add code to change back to a number after or something?

N00bDev
  • 1
  • 1

0 Answers0