
prompt();는 사용자에게 창을 띄워 값을 받는다.

console.log(typeof 변수이름);
const age = prompt("How old are you?"); //16
console.log(typeof age); //string
prompt의 값에 숫자를 입력해도 typeof를 해보면 string이라고 뜬다. string이 디폴트이기 때문이다.

숫자를 입력해도 typeof가 string이기 때문에 data type을 바꾸는 작업을 해야한다.
parseInt를 쓰면 된다.예를들어 "15"(string)을 15(number)로 바꿔보자.
const age = prompt("How old are you?");
console.log(typeof "15", typeof parseInt("15")); // string number
console.log(age, parseInt(age)); // 15 15

const age = parseInt(prompt("How old are you?")); //15
//⬇️
const age = parseInt("15");
//⬇️
const age = 15;
const.log(age); //15 <- number
숫자가 아닌 값이 입력되면 변환이 안된다.
NaN (Not a Number)이 뜬다.
'안뇽'과 같이 문자를 입력하고 number로 바꾸려고 하면 결과값은 NaN이 된다.


const age = parseInt(prompt("How old are you?"));
//⬇️
const age = parseInt("안뇽");
//⬇️
const.log(age); //NaN