I wonder if there is a method to exit function based on other function output.
In other words: I have a function that evaluates some values and if they are fine returns them, otherwise causes a warning to user.
const verifier = () => {
const a = Number(document.querySelector("#a").value);
const b = Number(document.querySelector("#b").value);
if(isNaN(a) || isNaN(b)) {
console.log("Sent notification to user");
return
}
return [a, b]
}
Now, I use it multiple times, e.g.:
const adder = () => {
const [a,b] = verifier() || return; // <--- HERE!
console.log(a);
console.log(b);
}
In HERE: if verification function returns false / undefined / null
I would like to exit my function prematurely, otherwise: assign to variables.