-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
43 lines (37 loc) · 851 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
$(document).ready(function() {
var number = "";
var displayDiv = $("#entry");
displayDiv.text("0");
var history = $("#history");
history.text("0");
var operators = ['+', '-', '*', '/'];
var expr="";
//for numbers
$(".number").click(function() {
number += $(this).text();
expr += $(this).text();
displayDiv.text(number);
history.text(expr);
});
//for operators
//
$('.operator').click(function() {
number += $(this).val();
expr +=$(this).val();
displayDiv.text(number);
history.text(expr);
});
//for all clear
$('.red').click(function() {
displayDiv.text("0");
history.text("0");
number="";
expr="";
})
//perform operation
$('#equalButton').click(function() {
number = eval(number);
displayDiv.text(number);
history.text(expr);
});
});