Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- input = [];
- i = 0;
- display = "";
- $(".screen").html("0");
- $(".button").on('click', function() {
- var value = $(this).attr("id");
- display = "";
- if (value == "C") {
- input.pop();
- console.log(input);
- i = i - 1;
- }
- else {
- input.push(value);
- console.log(input);
- i = i + 1;
- };
- for (var k = 0 ; k < input.length ; ++k) {
- display = display + input[k];
- }
- if (display === "") {
- $(".screen").html("0");
- }
- else {
- $(".screen").html(display);
- }
- }
- );
- $(".equal-button").on('click', function() {
- output = "";
- if (input[0] === "=") {
- output = 0
- }
- else {
- for (var j = 0 ; j < input.length - 1 ; ++j) {
- output = output+input[j];
- }
- }
- console.log(eval(output));
- $(".screen").html(eval(output));
- input = [];
- display = "";
- i = 0;
- }
- );
- $("#CE").on('click', function() {
- input = [];
- display = "";
- i = 0;
- $(".screen").html("0");
- }
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement