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

151
Vistas
I want to make a function more reusable by using a variable name store inside of a function parameter. How would I do that?

I want to make a function more reusable by being able to give variable name to it and modify the value of that variable within the function from that variable.

Kind of like this:

var number1;
function one(){
  number1 = 10;
  two(number1);
}
function two(varname){
  varname = varname * 10;
}

How can I do that?

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

0

If you send the variable through as a string, you can reference it using this

var number1;
function one(){
  number1 = 10;
  two("number1");
}
function two(varname){
  this[varname] = this[varname] * 10;
}

one()
console.log(number1)

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