diff --git a/jquery.calc.js b/jquery.calc.js
index 78bdd05..22634d6 100644
--- a/jquery.calc.js
+++ b/jquery.calc.js
@@ -11,6 +11,7 @@
jQuery(function($) {
var digits = $('#calculator .digits .digit');
+ var clear = $('#calculator .clear');
var calculator = { left: false, right: false, result: 0, operator: '+' };
function calculate() {
calculator.result = eval(calculator.left + calculator.operator + calculator.right);
@@ -30,6 +31,13 @@ jQuery(function($) {
var leftBuffer = '';
var rightBuffer = '';
+ clear.click(function() {
+ leftBuffer = '';
+ rightBuffer = '';
+ calculator = { left: false, right: false, result: 0, operator: '+' };
+ $('#calculator .result').text(calculator.result);
+ });
+
digits.click(function() {
var key = $(this).text();
console.log(leftBuffer, rightBuffer);