Skip to main content
replace "== false" with logical complement
Source Link
greybeard
  • 2.6k
  • 9
  • 40
  • 71

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

Initialize them as false, and if they all remain false at the end of the user being asked to select one of the options to make them true, then you restart the loop.

if(characterQuantity >= 8 && characterQuantity <= 128) {
        var lowerCase = false
        var upperCase = false
        var numeric = false
        var specialCharacters = false
        while (!lowerCase == false && !upperCase == false && !numeric ==  false && !specialCharacters == false) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (!lowerCase == false && !upperCase == false && !numeric == false && !specialCharacters == false) window.alert("It is not valid to not select any of these. Try again")
        }

Edit: I think you could use an object literal to make the code a bit cleaner, but that's an augmentation really, not strictly necessary to solve your problem.

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

Initialize them as false, and if they all remain false at the end of the user being asked to select one of the options to make them true, then you restart the loop.

if(characterQuantity >= 8 && characterQuantity <= 128) {
        var lowerCase = false
        var upperCase = false
        var numeric = false
        var specialCharacters = false
        while (lowerCase == false && upperCase == false && numeric ==  false && specialCharacters == false) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (lowerCase == false && upperCase == false && numeric == false && specialCharacters == false) window.alert("It is not valid to not select any of these. Try again")
        }

Edit: I think you could use an object literal to make the code a bit cleaner, but that's an augmentation really, not strictly necessary to solve your problem.

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

Initialize them as false, and if they all remain false at the end of the user being asked to select one of the options to make them true, then you restart the loop.

if(characterQuantity >= 8 && characterQuantity <= 128) {
        var lowerCase = false
        var upperCase = false
        var numeric = false
        var specialCharacters = false
        while (!lowerCase && !upperCase && !numeric && !specialCharacters) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (!lowerCase && !upperCase && !numeric && !specialCharacters) window.alert("It is not valid to not select any of these. Try again")
        }

Edit: I think you could use an object literal to make the code a bit cleaner, but that's an augmentation really, not strictly necessary to solve your problem.

Post Undeleted by Kenneth Mano
added 413 characters in body
Source Link

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

Initialize them as false, and if they all remain false at the end of the user being asked to select one of the options to make them true, then you restart the loop.

if(characterQuantity >= 8 && characterQuantity <= 128) {
        var lowerCase = false
        var upperCase = false
        var numeric = false
        var specialCharacters = false
        while (lowerCase == nullfalse && upperCase == nullfalse && numeric == null false && specialCharacters == nullfalse) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (lowerCase == false && upperCase == false && numeric == false && specialCharacters == false) window.alert("It is not valid to not select any of these. Try again")
        }

Edit: I think you could use an object literal to make the code a bit cleaner, but that's an augmentation really, not strictly necessary to solve your problem.

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

while (lowerCase == null && upperCase == null && numeric == null && specialCharacters == null) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (lowerCase == false && upperCase == false && numeric == false && specialCharacters == false) window.alert("It is not valid to not select any of these. Try again")

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

Initialize them as false, and if they all remain false at the end of the user being asked to select one of the options to make them true, then you restart the loop.

if(characterQuantity >= 8 && characterQuantity <= 128) {
        var lowerCase = false
        var upperCase = false
        var numeric = false
        var specialCharacters = false
        while (lowerCase == false && upperCase == false && numeric ==  false && specialCharacters == false) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (lowerCase == false && upperCase == false && numeric == false && specialCharacters == false) window.alert("It is not valid to not select any of these. Try again")
        }

Edit: I think you could use an object literal to make the code a bit cleaner, but that's an augmentation really, not strictly necessary to solve your problem.

Post Deleted by Kenneth Mano
Source Link

If I understand your question correctly, it should be sufficient to just nest the four ifs in a while loop?

while (lowerCase == null && upperCase == null && numeric == null && specialCharacters == null) {
            lowerCase = window.confirm("click OK to confirm lowercase letter."); 
            upperCase = window.confirm("Click OK to confirm uppercase letter.");
            numeric = window.confirm("Click OK to confirm numeric values");
            specialCharacters = window.confirm("Click OK to confirm special characters");
            if (lowerCase == false && upperCase == false && numeric == false && specialCharacters == false) window.alert("It is not valid to not select any of these. Try again")