The join() method joins all elements of an array into a string.
var name = ‘shane osbourne‘; var upper = name.split(‘ ‘) // [shane, osbourne] .map(x => x.charAt(0).toUpperCase() + x.slice(1)) // [Shane, Osbourne] .join(‘ ‘); console.log(upper);
时间: 2024-10-19 07:23:43