Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
I have to write a javascript function that takes in a string and returns true if "the string starts and ends with a vowel"

title basically. The question says create a function that takes in a string and returns true when the string starts and ends with a vowel. I must have read every possibly helpful/similar thread on here and still stuck. Please help

Tried too many things to even list. Its been literally hours I've been bashing my head against this problem.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

function test( word ){

  word = word.toUpperCase();
  
  let last = word[ word.length - 1 ];
    
  let vowels = [ 'A', 'E', 'I', 'O', 'U' ]

  if( vowels.includes( word[0]) && vowels.includes( last ) ){
    return true
  }else{
    return false
  }
}
about 4 years ago · Juan Pablo Isaza Report

0

:-)

You know how to create and execute a function?

You understand what startsWith and endsWith with does?

You know the && (and) and || (or) operators?

Try something like this:

function startsEndsWithAVowel(aString) {
  return (aString.startsWith('a') || aString.startsWith('e') || aString.startsWith('i') || aString.startsWith('o') || aString.startsWith('u')) && (aString.endsWith('a') || aString.endsWith('e') || aString.endsWith('i') || aString.endsWith('o') || aString.endsWith('u'));
}

Add uppercase vowels too.

This solution uses only a few constructs. If You learn more JavaScript you come up much better solutions.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!