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

243
Vistas
How do i automate inserting variables into the given statement?

How do I insert random words in the content line below? for eg : I want to insert hey, hello, hi in

{
    "content": ""
  }

and it prints

{
    "content": "hey"
  }
{
    "content": "hello"
  }
{
    "content": "hi"
  }
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

Set value to the object by method myObj[property] = value;

let obj = {};
const randomWordsArr = ["Hey", "Hello", "Hi"];

randomWordsArr.forEach((item)=>{ 
   obj["content"] = item;
   console.log(obj);
});

about 4 years ago · Juan Pablo Isaza Denunciar

0

I'm not sure if you're using Python or JS but if it is Python, there are several ways to do this depending on how clean you want it to be. The least clean and fastest option would be to use string manipulation. A better approach would be to maintain a dictionary which will allow you to switch around the value of content as much as you like, after which you can convert the dictionary to Json:

dictionary ={ 
  "content": ""
} 

dictionary["content"] = "hey"
      
json_object = json.dumps(dictionary) 
print(json_object)
about 4 years ago · Juan Pablo Isaza Denunciar

0

Your object must have a key be string and value be array. Like below these.

{
"key" : []
}

After that you can add all of the things in an Array value e.g.:

{
"key" : ["hi","hello","hey"]
}

And this is how to add some thing to your Array.

let obj = {}
obj.key = []
obj.key.push("hi")
obj.key.push("hello")
obj.key.push("hey")
//and show console
console.log(obj.key)
//Your can see 
["hi","hello","hey"]
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