Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

187
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda