Discuss / JavaScript / 第二题

第二题

Topic source
'use strict';
function string2int(s) {
    function str2array(x) {
        return x - '0';
    }
    function array2int(x, y) {
        return x * 10 + y;
    }
    arr = []
    for (k of s) {
    arr.push(k);
    }
    return arr.map(str2array).reduce(array2int);
}

  • 1

Reply