Discuss / JavaScript / 参考了一发!!

参考了一发!!

Topic source

第三题

'use strict';

function normalize(arr) {
  return arr.map(function(x) {
    return x[0].toLocaleUpperCase() + x.slice(1).toLocaleLowerCase();
  });
}

第二题

'use strict';

function string2int(s) {

  var a = s.split('');
  var b = a.map(function(x) {
    return x * 1;
  });
  var c = b.reduce(function(x, y) {
    return x * 10 + y;
  });
  return c
}

第一题

'use strict';

function product(arr) {

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

}

  • 1

Reply