首页 > 解决方案 > Python 的 Javascript 等效项 (input())

问题描述

Python:

num = int(input('Please enter a number between 0 to 6'))

def someFunction(num):
  # code here

如何在 JavaScript 中做到这一点?

标签: javascript

解决方案


如果要在浏览器上运行代码,可以使用 window 的prompt方法,从用户那里获取输入。

let num = parseInt(prompt("Please enter a number between 0 to 6"))

function someFunction(num){
  //code here
}


推荐阅读