用js編寫一個函數,從一個任意字符串中提取所有的數字,然后將它們添加在一起?
注意不能用正則表達式. 使用的知識點只能是js的語法范圍.
先謝過了
例如:
Input:“We have 30 apples will be handed out to 10 students who need it, containing 5 foreigners ”.<愛尬聊_生活百科> Output: 30 + 10 + 5 = 45
夢里纏綿的沙發A 18小時前
var str = We have 30 apples will be handed out to 10 students who need it, containing 5 foreigners;
杜宇 18小時前
typeof arr[i] === number
鐵小兔 18小時前
把字符串挨著掃描一遍不就完了……
