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

106
Vistas
How to create an objectBuilder function

Any help would be appreciated.

Create a function objectBuilder that takes in a number and returns an object whose keys are 0 up to number and the values are that same number multiplied by 5.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try using for loop

console.log(objectBuilder(5))

// declare function
function objectBuilder(number) {
  // declare empty object
  const obj = {}
  // loop from 0 to number
  for (let i = 0; i <= number; i += 1) {
    // set key of i to value of i * 5
    obj[i] = i * 5
  }
  // return object
  return obj
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can do it like this:

I am sorry that I am actually doing this @evolutionxbox

You can create JavaScript class that will do it for you:

class objectBuilder {
    constructor(number){
        for(let i=0;i<=number;++i) this[i]=i*5
    }
}
//to initiate it create new instance of a class
const newObj = new objectBuilder(5)

console.log(newObj)

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