Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. input = [];
  2. i = 0;
  3. display = "";
  4.  
  5. $(".screen").html("0");
  6.  
  7. $(".button").on('click', function() {
  8. var value = $(this).attr("id");
  9. display = "";
  10. if (value == "C") {
  11. input.pop();
  12. console.log(input);
  13. i = i - 1;
  14. }
  15. else {
  16. input.push(value);
  17. console.log(input);
  18. i = i + 1;
  19. };
  20. for (var k = 0 ; k < input.length ; ++k) {
  21. display = display + input[k];
  22. }
  23. if (display === "") {
  24. $(".screen").html("0");
  25. }
  26. else {
  27. $(".screen").html(display);
  28. }
  29. }
  30. );
  31.  
  32.  
  33. $(".equal-button").on('click', function() {
  34. output = "";
  35. if (input[0] === "=") {
  36. output = 0
  37. }
  38. else {
  39. for (var j = 0 ; j < input.length - 1 ; ++j) {
  40. output = output+input[j];
  41. }
  42. }
  43. console.log(eval(output));
  44. $(".screen").html(eval(output));
  45. input = [];
  46. display = "";
  47. i = 0;
  48. }
  49. );
  50.  
  51. $("#CE").on('click', function() {
  52. input = [];
  53. display = "";
  54. i = 0;
  55. $(".screen").html("0");
  56. }
  57. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement