Advertisement
Kamend1

Untitled

Mar 20th, 2025
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2.   let textValue = document.getElementById('text').value;
  3.   let textType = document.getElementById('naming-convention').value;
  4.  
  5.   let valueArray = textValue.toLowerCase().split(' ');
  6.   let result = ''
  7.  
  8.   if (textType === 'Camel Case') {
  9.     result = valueArray[0];
  10.     for (let i = 1; i < valueArray.length; i++) {
  11.       result += valueArray[i][0].toUpperCase() + valueArray[i].slice(1);
  12.     }
  13.   } else if (textType === 'Pascal Case') {
  14.     for (let word of valueArray) {
  15.       result += word[0].toUpperCase() + word.slice(1);
  16.     }
  17.   } else {
  18.     result = 'Error!';
  19.   }
  20.  
  21.   document.getElementById('result').textContent = result;
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement