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

154
Visualizações
How to count the vowels in a string and return an integer(with consecutive vowels counted twice!)?

So I came up with this, though the counter is not working properly.

const stringVowel = ('hottentottententententoonstellingsbedrijfsacademie')

const letters = stringVowel.split('');

const numberOfVowels = arr => arr.map(num => {
    let counter = 0;
    if (num === 'a' || num === 'o' || num === 'u' || num === 'e' || num === 'i') {
    counter++
    }
    console.log(counter)
})

numberOfVowels(letters)
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

One option is to use the string match method and provide a regular expression with all the vowels:

const withVowels = 'hottentottententententoonstellingsbedrijfsacademie';

const noVowels = 'wqdftzsqq';

function numberOfVowels(str) {
  return str.match(/[aeiou]/ig)?.length ?? 0;
}

console.log(numberOfVowels(withVowels));

console.log(numberOfVowels(noVowels));

Edit: Updated to a more robust solution based on comments

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