0

As in the title I keep getting a reference error and I have no idea why? Any help would be appreciated!

Error is the $ in line 1 of the javascript and the $ on line 20 of the javascript.

I have been searching the web for hours and cannot seem to find a solution to this any help would be appreciated!

I have tried searching the web but nobody seems to be having quite the same issue as me.


$(document).ready(function() {
    $("#backspace").click(function() { 
        var barValue = $("#bar").val();
        $("#bar").val(barValue.substring(0,barValue.length - 1));
    });

    $("#equal").click(function() {
        z1 = $("#bar").val();

        $("#history").append(z1 + "<br>");
    });
});

function c(val) {
    var a1 = $("#bar").val(val);
}

function v(val) {
    var sym = /\.|\+|\-|\*|\//
    var barValue = $("#bar").val();
    var lastChar = barValue.substring(barValue.length, barValue.length - 1);
    if (sym.test(lastChar) && sym.test(val)) {
    } else {
        var a2 = $("#bar").val($("#bar").val() + val);
    }
}

function equal() {
   $("#history").append($("#bar").val()+"=")
    var a3 = c(eval($("#bar").val()))
}

function reset() {
    var a4 = $("#bar").val("");
}

Error is the $ in line 1 of the javascript and the $ on line 20 of the javascript.

Tango-Dust
  • 11
  • 1

1 Answers1

-1

You must import jquery in your HTML, something like: <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>