Advertisement
Ivankooo1

funnySplit

Apr 8th, 2020
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input){
  2.   let isUpperCase = (c) => c === c.toUpperCase();
  3.   let words = [];
  4.  
  5.   let currentWord = input[0];
  6.  
  7.   for(let char of input.slice(1)){
  8.     if(!isUpperCase(char)){
  9.       currentWord += char;
  10.     }else{
  11.       words.push(currentWord);
  12.       currentWord = char
  13.     }
  14.   }
  15.   console.log(words.join(', '))
  16. }
  17. solve(
  18.   'SplitMeIfYouCanHaHaYouCantOrYouCan'
  19. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement