I am trying to create an Array in Javascript with some key:value pair. My initial array looks likes this:
var data = {
isPublic : true,
distance : 500,
noOfPlayer : 10
}
Now there is a checkbox, upon which upon checking I need to add more data to array. Say I check a box and need to update the array with its value and make the array look like this:
var data = {
isPublic : true,
distance : 500,
noOfPlayer : 10,
typePlay: 'amateur'
}
Can this be done, because I tried creating object with Key:value and pushing it to the array, but it gives and output as below:
var data =
[
{
isPublic : true,
distance : 500,
noOfPlayer : 10,
},
{
typePlay: 'amateur'
}
]
Please suggest.
Thanks, Ayush