I'm currently trying to stop a function that's currently being executed so it can be re-run, like a start/stop button. I've tried to use return; but I'm not sure if I'm using it wrong or not. I've tried throwing errors and that didn't work either.
An example would be like:
function testFunction(action) {
    if (action === "stop") {
        return;
    } else if (action === "start") {
        // do work
    }
}
testFunction("start");
// testFunction("stop"); (stop the function)```
 
    