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

220
Vistas
Print words with at least 4 consonants javascripts

Given the array ["cat", "dog", "reindeer", "penguin", "crocodile"], print all words with at least 4 consonants.

I don't know how to do it.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The commented code below can help you:

const animals = ["cat", "dog", "reindeer", "penguin", "crocodile"]
const vowels = ['a', 'e', 'i', 'o', 'u']

animals.forEach(animal=>{
  let counter=0
  //spliting the word in letters
  animal.split('').forEach(letter=>{
    //checking if the letter is really a letter and if it is not a vowel
    if(letter.toLocaleLowerCase()>='a'&&letter.toLocaleLowerCase()<='z'&&!vowels.some(v=>v===letter.toLocaleLowerCase()))
    counter++
  })
  if(counter>=4)
  console.log(animal)
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

With String match() method for pattern-matching, and Array.prototype.filter() for conditional screening of items, we can write a concise one-liner:

> const animals = ["cat", "dog", "reindeer", "penguin", "crocodile"]

> animals.filter( animal => animal.match(/[^aeiou]/gi).length >= 4)
["reindeer", "penguin", "crocodile"]

Do study regex as much as possible. Here are few resources: quick overview, deatiled demo

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