In my code, I have a standard data structure declared as
$scope.totals = {storage: 0, dailystorage: 0};
. Specifically, I am using an angular.forEach
loop that iterates over each element and adds the value of cam.storage
to $scope.totals.storage
, aiming to obtain the total storage count.
This is how I am implementing it:
$scope.totals.storage = $scope.totals.storage + cam.storage;
The issue I am encountering is when the values of two instances of cam.storage
are, for example, 21.09
and 15.82
, the outcome becomes 21.0915.82
instead of their actual sum - treating them as strings rather than numerical values.
How can I ensure the addition operation is performed correctly without concatenating the values together?