Why is typeof x never 'number' when x comes from the prompt function?

前端 未结 4 1137
予麋鹿
予麋鹿 2020-11-29 13:09

I\'m having trouble getting the first function (below) to work correctly. I want it to ask for the age of the user with two possible outcomes. If the user enters the correct

4条回答
  •  渐次进展
    2020-11-29 13:36

    It's returning a string, and parseInt will save you:

    ... 
      let age = parseInt(age_of_user());    
    ...
    

提交回复
热议问题