I use the following code to calculate the difference between two numbers.
function differenceCalculation(num1, num2) {
if (num1 > num2) {
return num1 - num2
} else {
return num2 - num1
}
}
On document.ready
var difference = differenceCalculation(visitorTime, firstOption);
console.log({difference});
This gives for instance the following values in the console:
visitorTime = 1831
firstOption = 1900
difference = 69
But since this should return the difference in time, I need it to do the calculation with 60
as the ceiling instead of the default 100
.
A simple solution would be to minus 40
from the difference, but is this a good solution?
var difference = ( differenceCalculation(visitorTime, firstOption) - 40 );