[Javascript] Array - join()

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);

 

posted @ 2015-10-09 01:04  Zhentiw  阅读(235)  评论(0)    收藏  举报