Discuss / JavaScript / 练习

练习

Topic source

练习1:reduce求积

    return arr.reduce(function(x,y){
        return x*y;
    });

练习2:string2int

    s.split("").map(function(x){
        return x - '0';
    }).reduce(function(x,y){
        return x*10 + y;
    });

练习3:规范输入

    return arr.map(function(x){
        return x[0].toUpperCase() + x.slice(1).toLowerCase();
    });

练习4:改正小明错

r = arr.map(Number);

  • 1

Reply