function returntime() {
var start = new Date().getSeconds();
var end = new Date().getSeconds();
var totaltime = end - start;
document.getElementById("Answer").innerHTML = totaltime;
}
The totaltime return 0 but when i put start or end it shows the output.
There is no delay between both statements.
var start = new Date().getSeconds();
var end = new Date().getSeconds();
You ask for seconds. The code runs faster than a second. For example, you get 9 seconds at the start and 9 seconds in the end. If you ask for the milliseconds you will see that you will have a different result.