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

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

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 Report

0

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

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

about 4 years ago · Juan Pablo Isaza Report

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 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!