i tried to write this function: http://uggedal.com/reddit.cf.algorithm.png in javascript:
function getRating(t,u,d){
var x = u-d;
if(x > 0)
y = 1
else if(x == 0)
y = 0
else if(x < 0)
y = -1
var z = Math.max(1,Math.abs(x));
return Math.log(z)/Math.log(10) + y*t/45000;
}
t = time in seconds between the first post and this post passed to the function
u = upvotes
d = downvotes
console.log(getRating(50000, 25, 25)); //0
But it always returns zero. Did i miss something? Thanks
edit: updated
For the example input, the result is 0, so that’s correct. Does it return 0 also for other inputs?
One thing, according to the link, you should set