I would like to continuously call the function below using setInterval() but only if the condition in the if statement evaluates to true.
Note: The function is global.
function view_stack(){
if(my_stack.size() > 0){
document.getElementById("stack_visual").innerHTML = my_stack.view();
} else {
swal("Ohhhh Noes", "There are no items in the stack!", "error");
}
}
Is there a way I can achieve it?