You are viewing a single comment's thread. Return to all comments →
I dont know whats is wrong its is cause i am using TypeScript I Think My Output Exaly Same
'use strict'; process.stdin.resume(); process.stdin.setEncoding('utf-8'); let inputString: string = ''; let inputLines: string[] = []; let currentLine: number = 0; process.stdin.on('data', function(inputStdin: string): void { inputString += inputStdin; }); process.stdin.on('end', function(): void { inputLines = inputString.split('\n'); inputString = ''; main(); }); function readLine(): string { return inputLines[currentLine++]; } function camelCase(word:string):string { let result = word.replace(/;/g,''); let code = result.slice(0,2); result = result.substring(2); if(code.toUpperCase().includes('M')){ if(result.includes('()')){ result = result.replace('()',''); } else{ result = result + '()' + ''; } } if(code[1].toUpperCase().includes("C")){ if(result === result.toLowerCase()){ result = result.replace(/\b[a-z]/g, (match) => match.toUpperCase()); } else { result = result.replace(/\b[A-Z]/g, (match) => match.toLowerCase()); } } if(code[0].toUpperCase().includes("C")){ let newRes = ""; let capitalNext = false; for(let char = 0;char < result.length;char++){ let a = result[char]; if(a == " "){ capitalNext = true; } else{ if(capitalNext){ capitalNext = false; a = a.toUpperCase() } newRes += a; } } result = newRes; } if(code.toUpperCase().includes('S')){ result = result.replace(/([A-Z])/g," $1").toLowerCase(); } return( result); } function main() { while (currentLine < inputLines.length) { const data = readLine(); if (data) { console.log(camelCase(data)); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Camel Case 4
You are viewing a single comment's thread. Return to all comments →
I dont know whats is wrong its is cause i am using TypeScript I Think My Output Exaly Same