-
Notifications
You must be signed in to change notification settings - Fork 138
Error in the solution to Exercise 3.4 #1138
Copy link
Copy link
Open
Description
Exercise 3.4 states:
...if an account is accessed more than seven consecutive times with an incorrect password, it invokes the function call_the_cops.
The current solution accounts for total, not consecutive atempts with an incorrect password.
I suggest resetting the counter to 0 after the account is accessed with a correct password.
function dispatch(m, q) {
if (invalid_attempts < 7) {
if (p === q) {
invalid_attempts = 0; // added
return m === "withdraw"
? withdraw
: m === "deposit"
? deposit
: "Unknown request: make_account";
} else {
invalid_attempts = invalid_attempts + 1;
return x => "Incorrect Password";
}
} else {
return calling_the_cops;
}
}
And adding a commented out successful request:
...
a("withdraw", "rosebad")(50);
// a("withdraw", "rosebud")(50);
a("withdraw", "rosebad")(50);
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels