DEV Community

Discussion on: Daily Challenge #95 - CamelCase Method

Collapse
 
asfo profile image
Asfo • Edited

Maybe not the best option :) but it works.
JS:

const camelCase = (str) => { if(typeof str !== 'string') { throw 'Not a string'; } return str.trim().toLowerCase().split(' ').map(el => { return el[0].toUpperCase() + el.slice(1); }).join(''); }