Discuss
/
JavaScript
/
第二题
第二题
Topic sourcefunction str2Int(s){ return s.split('').map(x=>+x).reduce((x,y)=>x*10+y); }
但是,其实,+s,就解决问题了。
请教一下,为什么 return +x;可以返回一个字符数组。
s='123456';
s.split("").map(function(x){
return +x;
});
[1, 2, 3, 4, 5]
- 1
徐志要搏出位-
第二题: return s.split(" ").map(function(x) {return x 1;}).reduce(function (x, y) { return x 10 + y;});