Q:

How to check if eval returns nothing in JS

If I want to check if an eval function returns nothing, how do I do it?
I tried to do something like:
    if (eval("iwuoinuvwoienvuwope") == "") {
     // Do something
     alert("Oh NO!");
    }

But when I do like that nothing happends.
Here is my full code:

function calc() {
  var cal = prompt("Your math....", "1 + 1");
  if (cal == null) {
    alert("If you don't have a math problem you can gtfo!");
  } else if (cal == false) {
    alert("If you don't have a math problem you can gtfo!");

  }
  
  /*  Here I Check if eval is empty  */
  /*  Here it doesn't work  */
  else if (eval(cal) == "") {
           alert("Could you be more specific");
           }
           
           /*       */
           
           
  else {
    alert("The answer is " + eval(cal));
  }
}
<button onclick="calc();">Calculator</button>

A:

eval(code) returns "the completion value of evaluating the given code. If the completion value is empty, undefined is returned." MDN
In your case, a valid math expression returns a Number. Thus you would have to check for typeof result == "Number". If you want to exclude NaN, Infinity and the like, perform additional checks e.g. by isFinite(result).

