String Ending with Vowel
Given an array of vowels in the prefilled code and a string
inputString as an input, write a JS program to check whether the inputString ends with a vowel.
Quick Tip
You can use the string methods toUpperCase() and endsWith().
Sample Input 1
Five
Sample Output 1
true
Sample Input 2
Apples grow best where there is cold in winter
Sample Output 2
false
let vowels = ['a','e','i','o','u'];
function vowelsCheck(input){
for(let i = 0; i < vowels.length; i++){
if(input.endsWith(vowels[i])){
return true;
}
}
return false;
}
let inp = "Apples grow best where there is cold in winter";
console.log(vowelsCheck(inp));
Comments
Leave a comment