Concepts Overview 5

Testing conditions in 'if else' loops

Create a credential validation system:
  • The email must contain an '@' and a '.', and be longer than 5 characters.
  • The password must not contain 'A', 'a', or 'IBM' (in any case), and be longer than 6 characters.
  • Repo



    Main js lines/commands used:

        
            console.log(email.indexOf("@") < 0); // false
            
    console.log(password.toUpperCase().includes("A")); // false
    console.log(/[Ii][Bb][Mm]/.test(password)); // false
    // avoid repetition function writeError(message, identifier) { document.querySelector(identifier).innerHTML = message; }
    Back to Concepts Overview