Monday 5 June 2017

nodejs math errors with .length averages on ubuntu 16.04

i tried with 2 versions of nodejs the one that shipped with 16.04 and 8

var x = [1, 2, 3, 4, 5];
var sum = x[0];


for (var i=0; i <x.length; i++){
  sum += i;
}

console.log(sum/x.length);


2.2
[Finished in 0.068s]


via vik

No comments:

Post a Comment