I have simplified what I'm presenting here, but I'm having some trouble "populating" a JSON structure with these 3 variables. I can't figure out how to create new objects and I end up storing all of name, age or state in 1 object. I'm using nodeJS, any tips would be appreciated.
const name = "Jason" + '\n' + "Freddy" + '\n' + "Chucky"
const age = "31" + '\n' + "25" + '\n' + "15"
const state = "CA" + '\n' + "NY" + '\n' + "PA"
console output will show this
Jason
Freddy
Chucky
31
25
15
CA
NY
PA
I want to take those values from the 3 variables and create this...
{
"overview":
[
{
"people":
[
{
"name": "Jason",
"age": "31",
"state": "CA"
},
{
"name": "Freddy",
"age": "25",
"state": "NY"
},
{
"name": "Chucky",
"age": "15",
"state": "PA"
}
]
}
]
}
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment