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

97
Vistas
NodeJs Array.join with text on each part of the array

So I want to make something that console logs

Name1 Is Ready
Name2 Is Ready
Name3 Is ready

and each name is in an array(so Something like this)

let array = []

array.push("Name1", "Name2", "Name3")

I can't seem to get it to work as I want since when I try to console log it with

console.log(array.join("\n") + "is Ready")

I get

Name1
Name2
Name3is ready

Is there any way to make it console log like

Name1 Is Ready
Name2 Is Ready
Name3 Is ready
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You have to loop through the array to achieve what you're looking for

like this

array.forEach(name => {
    console.log(name + "is Ready")
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

const array = ["Name1", "Name2", "Name3"]

array.forEach(node => {
  console.log(node + " is Ready!")
})

about 4 years ago · Juan Pablo Isaza Denunciar

0

If you have a number of elements all with the same prefix you can create an array, and then map over the array and join the elements into a string.

const arr = new Array(3)
  .fill(0)
  .map((_, i) => `Name${i + 1}`);

const str = arr.map(el => `${el} is ready`).join('\n');

console.log(str);

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