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

262
Views
How can I console log all rest paramaters without using a loop? (Including objects and no toString)

I got a mission that I must do which goes like this:

Write a function that does the following: it will accept any number of arguments and do console.log on all of them. Do not use loops.

Example and expected result:

result:

How am I supposed to do something like that without a loop?

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

0

use this :

function consoleAll(...args) {
    console.log(...args)
}

consoleAll("hello", 2, {name : "milad"})

/*output -> "hello", 2, {
  name: "milad"
}
*/
about 4 years ago · Juan Pablo Isaza Report

0

It's pretty simple but it depends on how you want to use this data you feel? But I suppose you could run an array length and sort your checks some how.

function MyHugeFunction (data) {
  console.log(`Size: ${data.length}`);
  console.log(`First Arg: ${data[0]}`);
  console.log(`Entire Argument Set: ${data}`);
};

MyHugeFunction(["test","hello","123"]);

about 4 years ago · Juan Pablo Isaza Report

0

It's not obvious without the context but I think it is an exercise on spread operator.

In this case, your function would be something like

function(...args) {
  args.forEach((val) => console.log(val))
}

or

function(...args) {
  console.log(...args)
}

The "...args" is used to get all the arguments of your function in a "args array" and the forEach function applied to this array does the trick

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!