I want to dynamically create as many variables as the number of color data read from json and assign the same color values to the created variables.
For example; blue colors dynamically incoming variable red colors dynamically incoming variable green colors dynamically incoming variable
then I want to store them in different dynamic arrays
{
"color": "red"
},
{
"color": "red"
},
{
"color": "green"
},
{
"color": "blue"
}
function datareadd(latitude, longitude, number) {
$.getJSON("json.json", function(dataa) {
var markers = [];
var renkler = [];
for (var i = 0; i < dataa.length; i++) {
markers[i] = [];
console.log(markers);
}
let grup = dataa.reduce((r, a) => {
r[a.color] = [...r[a.color] || [], a];
return r;
}, renkler);
console.log(grup.blue);
})
}
datareadd();