Game_Logic

My Calculator

May 8th, 2019 (edited)
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. document.body.innerHTML = "<input type='number' id='num1' placeholder='Number'><select id='operation'><option></option><option>+</option><option>-</option><option>×</option><option>÷</option></select><input type='number' id='num2' placeholder='Number'><button onclick='calc()'>Calculate</button><div id='result'><b><big>0</big></b></div>"; function calc() { var num1 = Number(document.getElementById('num1').value); var num2 = Number(document.getElementById('num2').value); var op = document.getElementById('operation').value; if (op == "+") { var add1 = num1 + num2; document.getElementById('result').innerHTML = "<b><big>"+add1+"</big></b>"; }; if (op == "-") { var minus1 = num1 - num2; document.getElementById('result').innerHTML = "<b><big>"+minus1+"</big></b>"; }; if (op == "×") { var multiply1 = num1 * num2; document.getElementById('result').innerHTML = "<b><big>"+multiply1+"</big></b>"; }; if (op == "÷") { var div1 = num1 / num2; document.getElementById('result').innerHTML = "<b><big>"+div1+"</big></b>"; }; };
Add Comment
Please, Sign In to add comment