let number2=prompt(" specify enter").trim(); // input= "25"
let number1="25";
console.log(Number(number2)) // output= NAN [NOT A NUMBER]
console.log(Number(number1)) // output= 25`
I have already asked chatgpt and chatgpt also agrees with me that if the input you entered is a string "25" , then the output should be same . the output should be :
25
25
2
Answers
You are treating a string like a number.
you could make sure that your string is a number before performing any Number specific operations on it.
shortest solution:
console.log(+number2)
The plus sign converts your string to a number.
prompt returns a string
You get NaN if you enter
"25"
with quotes since you will be trying to parse""25""