I am attempting to populate a multidimensional array with data from a JSON file.
The issue I am facing is that I am unable to update the content in the array:
if(j>i && hoursYy == hoursY && secondsX == secondsXx){
wocheArray[i].count = wocheArray[i].count + 1;
}
My intention was for the "count" to increment every time a duplicate is found in my JSON file. So far, I have been unable to find a solution online.
Just in case, here is the full code:
var myweek;
var x;
var y;
var id;
var count;
var wocheArray = [];
function preload(){
myweek = loadJSON("data/data.json");
}
function setup(){
createCanvas(windowWidth, windowHeight);
background(0);
//SAVE IN WOCHEARRAY
for (var i = 0; i < myweek.woche.length; i++) {
hoursY = myweek.woche[i].stunden;
secondsX = myweek.woche[i].sekunden;
for (var j=0; j< myweek.woche.length; j++){
hoursYy = myweek.woche[j].stunden;
secondsXx = myweek.woche[j].sekunden;
if(j>i && hoursYy == hoursY && secondsX == secondsXx){
wocheArray[i].count = wocheArray[i].count + 1;
}
else {
x = myweek.woche[i].stunden;
y = myweek.woche[i].sekunden;
id = myweek.woche[i].person;
count = 0;
}
wocheArray[i] = {x, y, count, id};
}
}
console.log(wocheArray);
}