Answer to Question #207552 in HTML/JavaScript Web Application for jayanth

Question #207552

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().

Input

  • The input will be a single line containing a string inputString

Output

  • The output should be a single line containing a boolean value

Sample Input 1

Five

Sample Output 1

true

Sample Input 2

Apples grow best where there is cold in winter

Sample Output 2

false




1
Expert's answer
2021-06-17T04:39:57-0400
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));

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS