I have this calculator that is very simple. I want to put little easter eggs, essentially, into the function of the code. Here is my codepen to show what I have done so far. I have commented out my attempts that haven't worked. I know that codepen doesn't show alerts so I have tried them the live page and the alerts still do not work. Here is the javascript
// Variables
var appendDigits = false
var prevResult = 0
var op = "="
//Functions
function clearDisplay() {
document.calculator.display.value = 0
prevResult = 0
appendDigits = false
op = "="
} //clear
function doOp(newop)
{
var newArg =eval(document.calculator.display.value)
if (op == "+") {
prevResult = prevResult + newArg
}
else if (op == "-") {
prevResult = prevResult - newArg
}
else if (op == "/") {
prevResult = prevResult / newArg
}
else if (op == "*") {
prevResult = prevResult * newArg
}
else if (op == "=") {
prevResult = newArg
}
// else if (newArg == 42) {
// alert("You have found the meaning of life, the universe, and everything.");
// }
else {
prevResult = newArg
}
document.calculator.display.value = prevResult
appendDigits = false
op = newop
} //doOp
function digit(dig) {
if (appendDigits) {
document.calculator.display.value += dig
}
else {
document.calculator.display.value = dig
appendDigits = true
}
}
//fuction meaning(document.calculator.display.value)
//{
// if ( "newArg" == "42" ) {
// alert("You have found the meaning of life, the universe, and everything.");
// }
// else {
// prevResult = newArg
// }
//}