I am new to javascript, and I need to calculate the difference between 2 timestamps (in seconds). one is when the user clicks on the first card, the other one is when he clicks on the last one.
my code:
var startTime = Date.now();
var endTime = Date.now();
var currentResult = ((endTime - startTime)/1000);
this gives NaN in the console, but I can see the long numbers if I do:
console.log(startTime);
console.log(endTime);
even when I use:
var startMillsecond = parseInt(startTime, 10);
var endMillsecond = parseInt(endTime, 10);
and then calculate:
currentResult = ((endMillsecond - startMillsecond)/1000);
it gives NaN as well. What am I doing wrong? I need to use only javascript.. Thanks for the help!