JSFiddle - React, Tailwind, and code Playground
JavaScript
tic = 1293840000; // UNIX time on January 1st, 2011 (0:0:0)
toc = 1325376000; // UNIX time on January 1st, 2012 (0:0:0)
YD025 = Math.round(31556926/25); // 1 year divided by 25 (in seconds)
YD225 = Math.round(31556926/225); // 1 year divided by 225 (in seconds)
// Item A recieves 25 votes during the year 2011
pA = tic; // pA is the popularity value for item A
for (i = tic; i < toc; i += YD025) {
pA = (pA + i)/2;
}
// Item B recieves 225 votes during the year 2011
pB = tic; // pB is the popularity value for item B
for (i = tic; i < toc; i += YD225) {
pB = (pB + i)/2;
}
if (pA > pB) {
alert("Item A (25 votes) has a higher popularity by " + Math.round(pA - pB));
}
if (pB > pA) {
alert("Item B (225 votes) has a higher popularity by " + Math.round(pB - pA));
}