How to execute a function after some time

javascript

Solution

You should use `setTimeout()`:

setTimeout(function() {
    getScore(); 
    getResult(); 
}, 1800000);

The '1800000' is the time in milliseconds after which you want this function to execute. In this case, 30 minutes.

Problem

I want to write a javascript code where I can execute a function after exactly 30 minutes. say I have a function called `getScore` and another function called `getResult`. I want those functions to be executed after exactly thirty minutes. It's for a quiz purpose, the quiz duration is thirty minutes, so after the time passes, both functions should be executed.

Original source