Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

244
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda