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

175
Views
a func called count and this func accepts 2 parameters and it'll return a string.If count(0,5).output: 0,1,2,3,4,5.I only slove this prblm in array

function count(param1, param2) {
  let value = [];
  for (let i = param1; i <= param2; i++) {
    value.push(i);
  }
  return value;
}
let countNumber = count(0, 10);
console.log(countNumber);

I want to show it as a string like 0,1,2,3,4,5. But I can't solve this problem. I can only solve this as an array. My output is [0,1,2,3,4,5].

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

0

You can try this:

function count (start, end) {
    console.log(Array.from({length: end-start+1}, (v, k) => k+start).join(","));
}
about 4 years ago · Juan Pablo Isaza Report

0

function count(param1, param2) {
  let value = [];
  for (let i = param1; i <= param2; i++) {
    value.push(i);
  }
  return value;
}
let countNumber = count(0, 10);
console.log(countNumber.toString());
about 4 years ago · Juan Pablo Isaza Report

0

Just join the array elements back into a string, and return that from your function.

function count(param1, param2) {
  const value = [];
  for (let i = param1; i <= param2; i++) {
    value.push(i);
  }
  return value.join(',');
}

const countNumber = count(0, 5);

console.log(countNumber);

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!