[Solved] Javascript small calculator app giving nan result


Try this code snippet and remember casting to Integers or Floats with parseInt or parseFloat

function mycalculator() {
  var a = parseInt(document.getElementById("a").innerHTML);
  var x = parseInt(document.getElementById("odrasli").value);
  var c = parseInt(document.getElementById("c").innerHTML);
  var y = parseInt(document.getElementById("deca").value);
  var aa = a * x;
  var cc = c * y;
  var p = aa + cc;
  var d = p * 0.2;
  document.getElementById("price").innerHTML = p;
  document.getElementById("depozit").innerHTML = d;
}
<div class="calculator">
  <div id="a">2</div>
  <div id="c">3</div>

  <input id="odrasli" type="number">
  <input id="deca" type="numbear">
  <input type="button" value="Get Price" onClick="mycalculator()">
  <div id="price"></div>
  <div id="depozit"></div>

0

solved Javascript small calculator app giving nan result