I have been trying to write this function but its not working...

Code:
 var buttondoit = document.getElementById("doit");
    buttondoit.addEventListener("click", function () {
       
        inputVal.value = eval(inputVal.value);
    }, false);
Code:
 
var buttondoit = document.getElementById("doit");    buttondoit.addEventListener("click", function () {
        alert(inputVal.value);
        var AA = JSON.parse(inputVal.value)
        inputVal.value = AA;
    }, false);
Both this code not working....

inputval.Value = is a textbox value which brings in text like

1 + 1

2 - 3