Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

267
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda