如何在JavaScript中将字符串转换为整数?
我需要添加用户输入的两个数字.为此,我创建了两个输入字段,从它们中检索值,使用.val(),在两个单独的变量中,然后添加它们.问题是添加了字符串而不是数字.例如.2 + 3变为23而不是5.请建议做什么,除了在输入框中使用type = number.
我有这个对象:
var sub = {
0: [""],
21: ["Look, here, are three little stuff,","ready to sing for this crowd"],
28: ["Listen up, 'cause here's our story","I'm gonna sing it very LOUUU..."],
36: [""],
45: ["VERY LOUUU..."],
48: [""],
61: ["When you're a younger stuff","and your stuff is very bare"],
68: ["Feels like the sun will never come","when your stuff's not there"],
74: ["So the three of us will fight the fight","there is nothing that we fear"],
80: ["We'll have to …Run Code Online (Sandbox Code Playgroud)