Skip to content

Instantly share code, notes, and snippets.

@RHeijnen
Created March 14, 2018 12:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RHeijnen/2e56fb3362eedef3149e0c8fcde053bf to your computer and use it in GitHub Desktop.
Save RHeijnen/2e56fb3362eedef3149e0c8fcde053bf to your computer and use it in GitHub Desktop.
var obj = require('./json.json');
var counter = 0;
var result = [];
for(var x = 0; x < obj.Data.length;x++){
var valueContainer = [];
for(var i = 0; i < obj.Data.length;i++){
try{
var itt = obj.Data[i].Data;
if(itt[counter].Value){
valueContainer.push(itt[counter].Value)
}
}catch(e){
}
};
var sum = 0;
for(var i = 0; i < valueContainer.length;i++){
sum = sum + valueContainer[i];
}
sum = sum / valueContainer.length;
result.push(sum)
counter = counter +1;
}
var workaroundContainer = [];
for(var i = 0; i < result.length;i++){
if(result[i]){
workaroundContainer.push(result[i])
}
}
console.log(workaroundContainer)
@RHeijnen
Copy link
Author

this is a piece of code a student showed me, LOL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment