Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!