Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- const inputText=document.querySelector('#text');
- const nameConvention=document.querySelector('#naming-convention');
- const result= document.querySelector('#result');
- const text=inputText.value;
- const convertToPascalCase= (text)=>
- text
- .split(' ')
- .map(word=> word.charAt(0).toUpperCase()+word.slice(1).toLowerCase())
- .join('');
- let convertor1= '';
- if(nameConvention.value== 'Pascal Case'){
- convertor1=(text)=> convertToPascalCase (text);
- /*(text)=>
- text
- .split(' ')
- .map(word=> word.charAt(0).toUpperCase()+word.slice(1).toLowerCase())
- .join('');*/
- }
- else if(nameConvention.value== 'Camel Case'){
- convertor1=(text)=> convertToPascalCase(text).charAt(0).toLowerCase()+
- convertToPascalCase(text).slice(1)
- }
- else{
- convertor1=()=>{return 'Error!'};
- }
- result.textContent=convertor1(text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement