Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!