Javascript calculator?

Could someone tell me how I can implement true or false statements if the calculation is right orwrong. I’m trying to create a calculator with a prompt which asks you for a certain calculation if the calculation is right a true statement should pop up if wrong a false statement should pop. It would also help me if someone has an idea on what I should code to make the prompt only poping up if the previous calculation is finished and you can see if the calculation is right or wrong not right after I typed in the result into the promp( newbie from germany)

var number = prompt("what is 1 + 1")

document.getElementById("taschenRechner").innerHTML = number
function rechnen () {
  if (prompt === 2) {
    return true
  } 
  return false
}
var number = prompt("what is 1 + 2")

document.getElementById("taschenRechner2").innerHTML = number
function rechnen () {
  if (prompt === 3) {
    return true
  } 
  return false
}
var number = prompt("what is 1 + 3")

document.getElementById("taschenRechner3").innerHTML = number
function rechnen () {
  if (prompt === 2) {
    return true
  } 
  return false
}
var number = prompt("what is 1 + 4")

document.getElementById("taschenRechner4").innerHTML = number
function rechnen () {
  if (prompt === 2) {
    return true
  } 
  return false
}

Your rechnen function never gets called and I’m not sure what’s about all those document.getElementById... (you haven’t provided the HTML part of your code), but one probable solution would be like this:

const prompts = [
  { q: "what is 1 + 1", a: 2 },
  { q: "what is 1 + 2", a: 3 },
  { q: "what is 1 + 3", a: 4 },
  { q: "what is 1 + 4", a: 5 }
];

const body = document.querySelector('body')
body.innerText = null

prompts.forEach(({ q, a }) => {
  const num = prompt(q);
  body.innerText += `${q}? Your answer ${num} is ${num == a}\n`
});

I hope this would get your juices running…