Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在 Code.org 的 Applab 中,我试图将文本输入框或下拉列表中的文本转换为整数,以便我可以使用它进行数学函数。但是, parseInt 似乎不起作用。如何将文本转换为整数?
您可以使用Number(). 例如,console.log(Number('2') + 2)输出4。
Number()
console.log(Number('2') + 2)
4