I'm currently trying to do some maths on my json data. But it's not doing what I want. I made a loop so the calculation apples to every row (by the way I work with angularJS)
Here's the part of my code where I'm trying to process the data :
angular.module('recordService', []).factory('recordService', ['$http', function($http) {
var url;
var recordService = [];
recordService.getAll = function(callback) {
url = "http://localhost/app/www/database/json.php";
$http({
url: url
}).then(function(rs) {
callback(rs.data);
function logArrayElements(element, index, array) {
var thdi = rs.data[index].THDI1_avg;
console.log(thdi + 5);
}
rs.data.forEach(logArrayElements);
}, function(err) {
console.log(err)
})
}
As you can see I trying to take one element from my array and add 5 to it (it's only a test; I want to do some more advanced math later). I can see in the console.log
that's its not doing what I want.
For example, if my data is 10.25, I get 10.255 when I would like 15.25. Any ideas on what I'm doing wrong?
Thanks in advance