-
Notifications
You must be signed in to change notification settings - Fork 0
/
7kyu-absentVowel.js
29 lines (22 loc) · 1.02 KB
/
7kyu-absentVowel.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
/*Your job is to figure out the index of which vowel is missing from a given string:
A has an index of 0,
E has an index of 1,
I has an index of 2,
O has an index of 3,
U has an index of 4.
Notes: There is no need for string validation and every sentence given will contain all vowels but one. Also, you won't need to worry about capitals.
Examples
"John Doe hs seven red pples under his bsket" => 0 ; missing: "a"
"Bb Smith sent us six neatly arranged range bicycles" => 3 ; missing: "o"*/
//P: one input, a string containing a sentence that will be missing one vowel from all of the places it should have been
//R: return the corresponding value of 0-4 for AEIOU for the vowel missing
//E: 'John Doe hs seven red pples under his bsket' => 0 (missing 'a')
//P: use if/else to check if the string includes each vowel, if it does not, return the corresponding index
let vowels = ['a', 'e', 'i', 'o', 'u']
function absentVowel(x){
for(let i = 0; i<vowels.length; i++){
if(!x.includes(vowels[i])){
return i;
}
}
}