My current task involves working with a stringified array:
JSON.stringify(arr) = [{"x":9.308,"y":6.576,"color":"yellow","restitution":0.2,"type":"static","radius":1,"shape":"square","width":0.25,"height":0.25},{"x":9.42,"y":7.488,"color":"yellow","restitution":0.2,"type":"static","radius":1,"shape":"square","width":0.25,"height":0.25}]
I must determine the frequency of occurrences of the word "yellow" within this data in order to proceed with the following operations:
numYellow = 0;
for(var i=0;i<arr.length;i++){
if(arr[i] === "yellow")
numYellow++;
}
doSomething = function() {
If (numYellow < 100) {
//do something
}
If(numYellow > 100) {
//do something else
} else { do yet another thing}
}