-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
35 lines (32 loc) · 818 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const input =
"This text will be translated into Whale talk - turpentine and turtles";
const vowels = ["a", "e", "i", "o", "u"];
const resultArray = [];
for (let i = 0; i < input.length; i++) {
//console.log('i is ' + i);
if (input[i] === "e") {
resultArray.push(input[i]);
}
if (input[i] === "u") {
resultArray.push(input[i]);
}
for (let j = 0; j < vowels.length; j++) {
//console.log('j is ' + j);
if (input[i] === vowels[j]) {
resultArray.push(vowels[j]);
}
}
}
console.log(resultArray);
/* Output:
[
'i', 'e', 'e', 'i', 'e', 'e',
'a', 'a', 'e', 'e', 'i', 'o',
'a', 'e', 'e', 'a', 'u', 'u',
'e', 'e', 'i', 'e', 'e', 'a',
'u', 'u', 'e', 'e'
]
*/
const resultString = resultArray.join("").toUpperCase();
console.log(resultString);
// IEEIEEAAEEIOAEEAUUEEIEEAUUEE