So I have one last thing I need the javascript calculator to do before I am finished. I want the calculator to run it’s equal function when an operator is pressed after having already pressed an operator and a number. Example , if I press “6” and then “+” and then “6” and then “+” again, I want the equals function to automatically activate. If I could get to that point, I would be able to delegate the other functions that would need to pass. I have code I have already written that aimed to accomplish this task but I am getting no such response from it
Here is my codepen https://codepen.io/DannyHz/pen/zjamKK/?editors=0011
Here is my javascript in case you just wanted to read that
$(document).ready(function(){
var x;
var memory = "";
var operator = "";
var equated = false;
function total(){
$("span").html(eval( (memory + operator + x)).toFixed(2));
operator = "";
keysPressed = "";
x = "";
equated = false;
}
function clear () {
$("#display").text("0");
memory = "";
x = "";
}
function clearKeys(){
keysPressed = "";
}
$("button").click(function(){
var display = $("#display").text();
var value = $(this).val();
if($(this).val()=="clear"){
clear();
}
else if ($("#display").text()=="0" || $("#display").text()=="-" || $("#display").text()=="+" || $("#display").text()=="/" ||
$("#display").text()=="*"){
x = $(this).val();
$("#display").text(x);
}
else if($(this).val()=="equals"){
total();
}
else if ($(this).attr('id')==="backOne" ){
var y = $("#display").text();
x = y.substring(0,y.length-1);
$("#display").text(x);
}
else if(display.indexOf(".")>-1 && value == "."){
x = x;
}
else if(value == "+" || value == "-" || value == "/" || value== "*"){
memory = x;
operator = value;
equated = true;
$("#display").text(value);
}
else if(equated == true && value == "+" || value == "-" || value == "/" || value== "*") {
total();
console.log('this');
}
else {
x = $("#display").text() + $(this).val();
$("#display").text(x);
}
});
});
Thanks in advance!