mercredi 7 octobre 2020

how to change a var value in "if"

I want to change p1 value when only first time then the second time the function is call I want to change p2. or is there any other(better) way to do this ?

function plus() {
  if (p1 == null){
  var p1 =  document.getElementById("label").value;
  reset();
} else {
  var p2 = document.getElementById("label").value + p1;
 document.getElementById("label").value = p2;
  }
 }

why doesn't this work

I am new to programming so, I am trying to create a calculator first.

Aucun commentaire:

Enregistrer un commentaire