Advertisement
ErolKZ

Untitled

Sep 27th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1.  
  2. String.prototype.camelCase = function () {
  3.  
  4.  
  5.  
  6. let arr = string.split('');
  7.  
  8. console.log(arr);
  9.  
  10.  
  11. for (let i = 0; i < arr.length; i++) {
  12.  
  13. if (i === 0) {
  14.  
  15. arr[i] = arr[i].toUpperCase();
  16.  
  17. } else if (arr[i] === ' ') {
  18.  
  19. arr[i + 1] = arr[i + 1].toUpperCase();
  20.  
  21. arr.splice(i, 1);
  22.  
  23. }
  24.  
  25. }
  26.  
  27.  
  28. return arr.join('');
  29.  
  30.  
  31. }
  32.  
  33.  
  34. // console.log(String.prototype.camelCase("test case"));
  35.  
  36. console.log("test case".camelCase());
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement