Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda