samedi 9 mai 2020

Hi all, why is a value assigned within an IF not show outside the IF?

Sorry, I am new at this, Does anyone know why doesn't my return within the IF work?

function telephoneCheck(str) {
  var a;
  let result = false;
  let str1 = str.split("");
  if (
    str1[0].isInteger === true &&
    str1[1].isInteger === true &&
    str1[2].isInteger === true &&
    str1[3] === "-" &&
    str1[4].isInteger === true &&
    str1[5].isInteger === true &&
    str1[6].isInteger === true &&
    str1[7] === "-" &&
    str1[8].isInteger === true &&
    str1[9].isInteger === true &&
    str1[10].isInteger === true &&
    str1[11].isInteger === true
  ) {
    return true;
  }
}
telephoneCheck("555-555-5555");

Aucun commentaire:

Enregistrer un commentaire