I'd like to ask the user to input a number again when entering a string using the while, but it comes out as NaN and the while.. does not work [duplicate]
let getInch = prompt('Cm로 바꾸고 싶은 Inch 값을 넣으세요','숫자만 입력하세요');
let numInch = Number(getInch);
while (numInch == NaN) {
alert(`숫자만을 입력하세요`);
getInch = prompt('Cm로 바꾸고 싶은 Inch 값을 넣으세요');}
let numCm = Math.round(numInch * 25.4) / 10;
alert(`${numInch}인치는 대략 ${numCm}센치미터 입니다`);
Use isNAN() method instead of == NaN
https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/isNaN