Spaces:
Running
Running
| <html> | |
| <head> | |
| <title>Manipulate Word</title> | |
| <link rel="shortcut icon" type="x-icon" href="https://s3.amazonaws.com/moonup/production/uploads/64364379a4bd75c62cc350c1/Qokf8E9WBPXQT-sLhsrYy.png"> | |
| <style> | |
| body { | |
| font-family: Arial, sans-serif; | |
| text-align: center; | |
| } | |
| form { | |
| margin-top: 50px; | |
| } | |
| label { | |
| display: block; | |
| margin-bottom: 10px; | |
| } | |
| input[type="text"] { | |
| padding: 10px; | |
| border: 1px solid #ccc; | |
| border-radius: 4px; | |
| width: 300px; | |
| } | |
| button[type="button"] { | |
| padding: 10px 20px; | |
| margin: 5px; | |
| background-color: #4CAF50; | |
| color: #fff; | |
| border: none; | |
| border-radius: 4px; | |
| cursor: pointer; | |
| } | |
| </style> | |
| <script> | |
| function addVowels() { | |
| var wordInput = document.getElementById("word"); | |
| var vowels = "aeiou"; | |
| var newWord = ""; | |
| for (var i = 0; i < wordInput.value.length; i++) { | |
| newWord += wordInput.value[i]; | |
| if (i < wordInput.value.length - 1 && !vowels.includes(wordInput.value[i + 1])) { | |
| newWord += vowels.charAt(Math.floor(Math.random() * vowels.length)); | |
| } | |
| } | |
| wordInput.value = newWord; | |
| } | |
| function removeVowels() { | |
| var wordInput = document.getElementById("word"); | |
| var vowels = "aeiouAEIOU"; | |
| var newWord = ""; | |
| for (var i = 0; i < wordInput.value.length; i++) { | |
| if (!vowels.includes(wordInput.value[i])) { | |
| newWord += wordInput.value[i]; | |
| } | |
| } | |
| wordInput.value = newWord; | |
| } | |
| function addConsonants() { | |
| var wordInput = document.getElementById("word"); | |
| var consonants = "bcdfghjklmnpqrstvwxyz"; | |
| var newWord = ""; | |
| for (var i = 0; i < wordInput.value.length; i++) { | |
| newWord += wordInput.value[i]; | |
| if (i < wordInput.value.length - 1 && !consonants.includes(wordInput.value[i + 1])) { | |
| newWord += consonants.charAt(Math.floor(Math.random() * consonants.length)); | |
| } | |
| } | |
| wordInput.value = newWord; | |
| } | |
| function removeConsonants() { | |
| var wordInput = document.getElementById("word"); | |
| var consonants = "bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"; | |
| var newWord = ""; | |
| for (var i = 0; i < wordInput.value.length; i++) { | |
| if (!consonants.includes(wordInput.value[i])) { | |
| newWord += wordInput.value[i]; | |
| } | |
| } | |
| wordInput.value = newWord; | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <form> | |
| <label for="word">Enter a word:</label> | |
| <input type="text" id="word" name="word"> | |
| <br> | |
| <button type="button" onclick="addVowels()">Add Vowels</button> | |
| <button type="button" onclick="removeVowels()">Remove Vowels</button> | |
| <button type="button" onclick="addConsonants()">Add Consonants</button> | |
| <button type="button" onclick="removeConsonants()">Remove Consonants</button> | |
| </form> | |
| </body> | |
| </html> | |