How to check an if condition for 5 seconds? This if condition should be true for 5 seconds to execute its code.
function checkcodition() {
You should use browser APIs setTimeout function.
This example will only check the condition AFTER five seconds, not DURING five second interval. If you want to make sure the condition stays true during whole interval, you should probably implement some onValueChange() type event.
function checkCodition() {
let a, b;
setTimeout(() => {
if (a === 0 && b === 1) {
console.log(" This line shoud display after 5 seconds");
}
}, 5000);
}
Additional info:
You should use tripple equality sign ===, use let instead of var and camelCase insted of lowercase for function names.