Last active
September 7, 2023 08:53
-
-
Save unes/637dd13cc2d18a685c8c2c6b37f3ae40 to your computer and use it in GitHub Desktop.
Whale Talk - JavaScript (from Codecademy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* translates "turpentine and turtles" to "whale talk" languag, outputs "UUEEIEEAUUEE" | |
*/ | |
const input = 'turpentine and turtles'; | |
const vowels = ['a', 'e', 'i', 'o', 'u']; | |
const resultArray = []; | |
for(let i = 0; i < input.length; i++) { | |
for(let j = 0; j < vowels.length; j++) { | |
if (input[i] === vowels[j]) { | |
resultArray.push(input[i]); | |
} | |
} | |
if (input[i] === 'e') { | |
resultArray.push(input[i]); | |
} | |
if (input[i] === 'u') { | |
resultArray.push(input[i]); | |
} | |
} | |
console.log(resultArray.join('').toUpperCase()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment