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 inputString = prompt('Enter a string: ')
let str = inputString.toUpperCase()
if (str.endsWith('E') || str.endsWith('U') || str.endsWith('I') || str.endsWith('O') || str.endsWith('A')) {
console.log('true')
} else {
console.log('false')
}
Sample Input 1:
Five
Sample Output 1:
true
Comments
Leave a comment