javascript - 一个简单练习题目的问题求解
巴扎黑
巴扎黑 2017-04-10 14:44:03
0
1
297

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()
}
巴扎黑
巴扎黑

reply all(1)
迷茫
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();
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template