title: Eval() in if statement
body: <p><strong>HTML &amp; JS</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;Calculator&lt;/title&gt;
      &lt;!-- Allows me to use jQuery --&gt;
      &lt;script&gt;
      if (typeof module === 'object') {window.module = module; module = undefined;}
      &lt;/script&gt;
      &lt;script src="assets/libraries/jq.js"&gt;&lt;/script&gt;
      &lt;link rel="stylesheet" href="assets/css/style.css"&gt;
      &lt;!-- End of "Allows me to use jQuery" --&gt;
      &lt;script&gt;
      if (window.module) module = window.module;
    &lt;/script&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;!-- "vysledek" means in English "result" --&gt;
      &lt;input id="vysledek" type="text" autofocus&gt;
          &lt;br&gt;
                    &lt;!-- "kalkulacka" means in my language "calculator" --&gt;
        &lt;button class="C" onClick="kalkulacka('C')"&gt;C&lt;/button&gt;
        &lt;button onClick="kalkulacka('(')"&gt;(&lt;/button&gt;
        &lt;button onClick="kalkulacka(')')"&gt;)&lt;/button&gt;
        &lt;button onClick="kalkulacka('/')"&gt;&amp;#247;&lt;/button&gt;
          &lt;br&gt;
        &lt;button onClick="kalkulacka(7)"&gt;7&lt;/button&gt;
        &lt;button onClick="kalkulacka(8)"&gt;8&lt;/button&gt;
        &lt;button onClick="kalkulacka(9)"&gt;9&lt;/button&gt;
        &lt;button onClick="kalkulacka('*')"&gt;&amp;#215;&lt;/button&gt;
          &lt;br&gt;
        &lt;button onClick="kalkulacka(4)"&gt;4&lt;/button&gt;
        &lt;button onClick="kalkulacka(5)"&gt;5&lt;/button&gt;
        &lt;button onClick="kalkulacka(6)"&gt;6&lt;/button&gt;
        &lt;button onClick="kalkulacka('-')"&gt;&amp;#8722;&lt;/button&gt;
          &lt;br&gt;
        &lt;button onClick="kalkulacka(1)"&gt;1&lt;/button&gt;
        &lt;button onClick="kalkulacka(2)"&gt;2&lt;/button&gt;
        &lt;button onClick="kalkulacka(3)"&gt;3&lt;/button&gt;
        &lt;button onClick="kalkulacka('+')"&gt;&amp;#43;&lt;/button&gt;
          &lt;br&gt;
        &lt;button onClick="kalkulacka('.')"&gt;,&lt;/button&gt;
        &lt;button onClick="kalkulacka(0)"&gt;0&lt;/button&gt;
        &lt;button onClick="kalkulacka('=')"&gt;=&lt;/button&gt;
        &lt;button onClick="kalkulacka('⌫')"&gt;⌫&lt;/button&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  
  
  &lt;script&gt;
  // "boxik" here just represents that input field
  const boxik = document.getElementById("vysledek");
  
  function kalkulacka(x) {
    if (x == "C") {
      //This clears whole input
      boxik.value = "";
    } else if (x == "⌫") {
      //This removes last digit
      boxik.value = boxik.value.substring(0, boxik.value.length-1);
    } else if (x == "=") {
      //Here is our problem, I expect this to check if it was calculated or
      //not      
      if (eval(boxik.value)) {
        boxik.value = eval(boxik.value);
      } else {
        $("#vysledek").css("border-bottom", "2px solid #bd1515");
      }
    }
    //This basically adds all digits, + etc. together
    else {
      boxik.value += x;
    }
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>Here is working JSFiddle: <a href="https://jsfiddle.net/mg7zmLos/7/" rel="nofollow noreferrer">https://jsfiddle.net/mg7zmLos/7/</a></p>
  
  <p>So basically today I started with Electron and I'm working on calculator app which I just hard-coded, but it works (it isn't completed so far) but I want to check if my calculation went good or not, if yes then I just want to do <code>boxik.value = eval(boxik.value)</code> and if it screws then make my border red using jQuery <code>$("#vysledek").css("border-bottom", "2px solid #bd1515")</code> but I don't know how to check if it screwed or not...</p>