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

143
Views
Is there any way I can print multiple elements each of an array twice on separate lines?

My code so far prints the whole array twice but I want to print each array element twice such that "Daudu" appears twice side by side etc and others like that on separate lines.

let Smart = ["Daudu", "Emma", "Skodo", "John", "Jones", "Mike", "Sierra", "Oscar", "Alpha", "Bravo"];
console.log(Smart.join('\r\n'));
console.log(Smart.join('\r\n'));

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Like that?

let Smart = ["Daudu", "Emma", "Skodo", "John", "Jones", "Mike", "Sierra", "Oscar", "Alpha", "Bravo"];
Smart.forEach(element => console.log(element, element));

about 4 years ago · Juan Pablo Isaza Report

0

You can use a for loop

const smart = ['Daudu', 'Emma', 'Skodo', 'John', 'Jones', 'Mike', 'Sierra', 'Oscar', 'Alpha', 'Bravo'];

for (const item of smart) {
    console.log(`${item}, ${item}`);
}

Or you can create a new array then do the same thing as above

const smart = ['Daudu', 'Emma', 'Skodo', 'John', 'Jones', 'Mike', 'Sierra', 'Oscar', 'Alpha', 'Bravo'];

const newSmart = smart.map((item) => `${item}, ${item}`);

for (const item of newSmart) {
    console.log(item);
}

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!