Created
June 6, 2020 22:01
-
-
Save Higokian/fbfe3014842e77d8a7539f0c061f3960 to your computer and use it in GitHub Desktop.
Whale translator - Translates words into wale language
This file contains hidden or 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
// Create input variable and necessary | |
// arrays | |
let input = 'hello, human'; | |
const vowels = ['a', 'e', 'i', 'o', 'u']; | |
let resultArray = []; | |
// Create for loop to sift through each letter | |
// of the input and compare them to vowels | |
// (whale letters) | |
for(i = 0; i < input.length; i++) { | |
//console.log(i); | |
for(j = 0; j < vowels.length; j++) { | |
if(input[i] === vowels[j]) { | |
resultArray.push(vowels[j]); | |
} | |
} | |
// Inside outer loop, double 'e' and 'u' vowels | |
if(input[i] === 'e') { | |
resultArray.push(input[i]); | |
} | |
if(input[i] === 'u') { | |
resultArray.push(input[i]); | |
} | |
} | |
// Log the input translated to whale | |
console.log(resultArray.join('').toUpperCase()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment