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

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

모든 응답(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();
}
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿