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

189
Views
Put hashtags in a string in javascript

my problem is quite simple, I would like to put hashtags in a text from a list of them. I have tried every way but I can't find the solution. Thanks in advance.

let arr = ['aa', 'bb']

let caption = `Hello | World `;

arr.forEach(el => {
  console.log(`#${el}`)
  caption.concat(' ', `#${el}`)
});

console.log(caption) // I want : "Hello | World #aa #bb" ; But it puts me "Hello | World"
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

concat does not modify the original string. You have to assign the returned value of concat back to caption.

let arr = ['aa', 'bb']

let caption = `Hello | World `;

arr.forEach(el => {
  console.log(`#${el}`)
  caption = caption.concat(' ', `#${el}`)
});

console.log(caption) // prints : "Hello | World #aa #bb"

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!