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

110
Vistas
After "," in array set <br />

I have:

var a = ['bla bla bla', 'bla bla', 'bla']

and would like when I display this HTML, after every , to be new line (<br />), but I do not know how to do this. I tried this:

var a = ['bla bla bla', 'bla, bla', 'bla']
{a.map(b => {
  return b + <br />   //but this getting error .... whitout <br /> don't get error but doesn't have new line
})
}

I do not know how long array a will be, because of this I did not do:

{a[0] } 
<br /> 
{a[1]} 
<br /> 
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You should return a JSX Element:

a.map(b => {
  return <>{b}<br /></>
});

You need the <> and </> since you can only return a single value. More on fragments here.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You don't want to use map here. Try join instead.

const fullString = a.join('<br/>')

Though, it's really unclear how you are outputting this.

about 4 years ago · Juan Pablo Isaza Denunciar

0

Instead of adding "<br />", I recommend to use built in JSON functions:

var a = ['bla bla bla', 'bla, bla', 'bla'];
a = JSON.stringify(a, null, 4)
document.getElementById("output").innerText = a
<div id="output"></div>

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