Advertisement
Silviya7

ArrowFunction

Apr 3rd, 2024 (edited)
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2.  
  3.   const inputText=document.querySelector('#text');
  4.   const nameConvention=document.querySelector('#naming-convention');
  5.   const result= document.querySelector('#result');
  6.   const text=inputText.value;
  7.  
  8.   const convertToPascalCase= (text)=>
  9.   text
  10.   .split(' ')
  11.   .map(word=> word.charAt(0).toUpperCase()+word.slice(1).toLowerCase())
  12.   .join('');
  13.  
  14.  
  15. let convertor1= '';
  16. if(nameConvention.value== 'Pascal Case'){
  17.   convertor1=(text)=> convertToPascalCase (text);
  18.  
  19.   /*(text)=>
  20.   text
  21.   .split(' ')
  22.   .map(word=> word.charAt(0).toUpperCase()+word.slice(1).toLowerCase())
  23.   .join('');*/
  24. }
  25. else if(nameConvention.value== 'Camel Case'){
  26.   convertor1=(text)=> convertToPascalCase(text).charAt(0).toLowerCase()+
  27.   convertToPascalCase(text).slice(1)
  28.  
  29. }
  30. else{
  31.   convertor1=()=>{return 'Error!'};
  32. }
  33.  
  34. result.textContent=convertor1(text);
  35.  
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement