$(function(){
  numClicked();
  opClicked();
  doAllTheMaths();
  clearAll();
  toggleNegative();
});

var nums = [];
var parsedNums = [];
var hasBeenToggled, toggled;


function clearAll(){
  $('#clearAll').on('click', function(){
    nums = [];
    parsedNums = [];
    $('input').val('');
    hasBeenToggled = 0;
  });
}

function toggleNegative(){
  hasBeenToggled = 0;
  // toggled;
  $('#plus-minus').on('click', function(){
    if(!hasBeenToggled){
      hasBeenToggled ++;
      toggled = parseInt(nums.join("")) * -1;
      nums = [];
      $('input').val(toggled);
      console.log(toggled);
    }
    else{
      $('input').val(toggled * -1);
      toggled = toggled * -1;
      console.log(toggled);
    }
  });
}

function numClicked(){
  $(".number").on("click", function(){
    nums.push($(this).text().trim());
    console.log(nums);
    $('input').val(nums.join(""));
  });
}

var ops = [], result;
function opClicked(){
  var $op;
  $(".ops").on("click", function(){
    $op = $(this).attr('value');
    console.log($op);
    var numSet = toggled ? toggled: parseInt(nums.join(''));
    toggled = '';
    console.log(toggled);
    nums = [];
    parsedNums.push(numSet);
    console.log(numSet);
    console.log(parsedNums);
    if(!ops[0] && $op !== "="){
      ops.push($op);
    }
    else{
      opToPass = ops.pop();
      if($op !== "=")
      ops.push($op);
      console.log(opToPass);
    }
    if(parsedNums.length === 2){
      result = calculate(opToPass)[0];
      console.log(result);
      $('input').val(result);
    }
  });
}

function calculate(opToPass){
  var result;
  switch (opToPass) {
    case "+":
      result = parsedNums.reduce(function(a, b){
        return a + b;
      });
      break;
    case "-":
      result = parsedNums.reduce(function(a, b){
        return a - b;
      });
      break;
    case "/":
      result = parsedNums.reduce(function(a, b){
        return a / b;
      });
      break;
    case "*":
      result = parsedNums.reduce(function(a, b){
        return a * b;
      });
      break;
    case "=":
        console.log(opToPass);
      break;
    default:
  }
  parsedNums = [];
  parsedNums.push(result);
  return parsedNums;
}

function doAllTheMaths(){
  $('#equals').on('click', function(){
    console.log(result);
    parsedNums = [];
    nums[0] = result;
    $('input').val(nums[0]);
  });
}

@@ -91,16 +91,31 @@
 tive();%0A
+  toPercent();%0A
 %7D);%0A%0Avar
@@ -174,16 +174,28 @@
  toggled
+, percentage
 ;%0A%0A%0Afunc
@@ -398,22 +398,8 @@
  0;%0A
-  // toggled;%0A
   $(
@@ -726,32 +726,227 @@
 %0A    %7D%0A  %7D);%0A%7D%0A%0A
+function toPercent()%7B%0A  $('#percent').on('click', function()%7B%0A    percentage = parseInt(nums.join(%22%22)) / 100;%0A    console.log(percentage);%0A    nums = %5B%5D;%0A    $('input').val(percentage);%0A  %7D);%0A%7D%0A%0A
 function numClic
@@ -1271,17 +1271,45 @@
 led 
-? toggled
+%7C%7C percentage ? toggled %7C%7C percentage
 : pa
@@ -1349,16 +1349,37 @@
 d = '';%0A
+    percentage = '';%0A
     cons

include percentage op with chaining