I have an on click event that changes the values of three elements that I want to combine into a json-like object:
function generateNumbers() {
let a = Math.random()
let b = Math.random()
let c = Math.random()
console.log({
"numbers": [
{"a": a, "b": b, "c": c}
]
})
}
<button onclick="generateNumbers()">Three Numbers</button>
Rather than replace a, b, and c I want to add another object {"a": a, "b": b, "c": c} with each click. Is this possible?
Desired Output
{
"numbers": [
{
"a": 0.795741457922079,
"b": 0.07941685760724382,
"c": 0.048012832026655516
},
{
"a": 0.17600389141580575,
"b": 0.4720288949307833,
"c": 0.8079844242898715
},
]
}