JavaScript 不算很好,所以找了个做题升级的网站talentbuddy.co练习一下。可是这个网站没法看答案,除非你解决了这个题。
For example
s: " one, ,two three,4,"
4//one two three 4
s:" ,"
0//
请写一个函数
function count_words(s) {
//console.log()
}
接下来的另一题Sort words
For example
s: " one, ,two three,4,"
//输出 4 one three two
function sort_words(s) {
//console.log()
}
迷茫2017-04-10 14:46:03
function count_words(s){
return s.split(/[, ]/g).filter(function(v){return v}).length;
}
function sort_words(s){
return s.split(/[, ]/g).filter(function(v){return v}).sort();
}