mardi 29 septembre 2020

Javascript - If condition is met, return True for specific amount of time, then false

I'm trying to code a function that, if some conditions are met, it returns "true" for some time, then return false again, even if the condition is still true.

The idea of the code is something like this:

if(condition is met)
    {return 'True' for 3000ms then 'false'} //even if the condition it's still 'true'
        else {False}

I can easily program the result of the condition (returning true or false if met), but i'm having a lot trouble trying to (if true) returning it for a specific amount of time.

NOTE: a function with setTimeout() is not an option in this case.

Thanks!

Aucun commentaire:

Enregistrer un commentaire