Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String.prototype.camelCase = function () {
- let arr = string.split('');
- console.log(arr);
- for (let i = 0; i < arr.length; i++) {
- if (i === 0) {
- arr[i] = arr[i].toUpperCase();
- } else if (arr[i] === ' ') {
- arr[i + 1] = arr[i + 1].toUpperCase();
- arr.splice(i, 1);
- }
- }
- return arr.join('');
- }
- // console.log(String.prototype.camelCase("test case"));
- console.log("test case".camelCase());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement