Advertisement
pacho_the_python

Untitled

Feb 23rd, 2023
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function splitPascalCase(someString) {
  2.     let transformedList = []
  3.     let word = ''
  4.  
  5.     while (someString.length >0) {
  6.         let ch = someString[0]
  7.         if (word.length === 0 && ch === ch.toUpperCase()) {
  8.             word += ch
  9.         }
  10.         else if (word.length > 0 && ch === ch.toLowerCase()) {
  11.             word += ch
  12.         }
  13.         else {
  14.             transformedList.push(word)
  15.             word = ''
  16.             word += ch
  17.         }
  18.         someString = someString.slice(1)
  19.     }
  20.  
  21.     transformedList.push(word)
  22.  
  23.     console.log(transformedList.join(', '))
  24. }
  25.  
  26. splitPascalCase('SplitMeIfYouCanHaHaYouCantOrYouCan')
  27.  
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement