Created
February 8, 2018 01:48
-
-
Save albert-massey/76b5a2953e4a18efb521e966c992ba73 to your computer and use it in GitHub Desktop.
Check your balance at the ATM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Programming Quiz - Checking Your Balance (3-5) | |
*/ | |
// change the values of `balance`, `checkBalance`, and `isActive` to test your code | |
var balance = 0; | |
var checkBalance = false; | |
var isActive = true; | |
if (checkBalance === true) { | |
if (balance > 0 && isActive === true) { | |
console.log("Your balance is $" + balance + "."); | |
} else { | |
if (isActive === false) { | |
console.log("Your account is no longer active."); | |
} else if (isActive === true) { | |
if (balance === 0) { | |
console.log("Your account is empty"); | |
} else if (balance < 0) { | |
console.log("Your balance is negative. Please contact bank."); | |
} | |
} | |
} | |
} else if (checkBalance === false) { | |
console.log("Thank you. Have a nice day!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is what I have. I've tested it a bunch of times and I'm still told I have it wrong; It might not be pretty but it runs fine.
if (checkBalance && balance>0 && isActive) {console.log("Your account balance is $" + balance + ".");
} else if (checkBalance && balance === 0 && isActive) {console.log("Your account is empty.");
} else if (checkBalance && balance < 0 && isActive) {console.log("Your balance is negative. Please contanct bank.");
} else if (!isActive) {console.log ("Your account is no longer active.");
} else if (!checkBalance) {console.log("Thank you. Have a nice day!");
}