Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve() {
- let text = document.getElementById('text').value;
- let nameConv = document.getElementById('naming-convention').value;
- if (nameConv === "Camel Case") {
- text = text.split(' ');
- text = text.map(el => el.toLowerCase());
- text = text.map(el => el.split(''));
- for (let i = 1; i < text.length; i++) {
- text[i][0] = text[i][0].toUpperCase();
- }
- text = text.flat();
- text = text.join('');
- } else if (nameConv === "Pascal Case") {
- text = text.split(' ');
- text = text.map(el => el.toLowerCase());
- text = text.map(el => el.split(''));
- for (let i = 0; i < text.length; i++) {
- text[i][0] = text[i][0].toUpperCase();
- }
- text = text.flat();
- text = text.join('');
- } else if (nameConv === "Another Case") {
- text = 'Error!';
- }
- let result = document.getElementById('result');
- result.textContent = text;
- console.log(text);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement