up
This commit is contained in:
parent
ab9ab64bd5
commit
97c8f22bbb
289 changed files with 195 additions and 172 deletions
|
@ -0,0 +1,38 @@
|
|||
importance: 5
|
||||
|
||||
---
|
||||
|
||||
# Ask loosing this
|
||||
|
||||
The call to `askPassword()` in the code below should check the password and then call `user.loginOk/loginFail` depending on the answer.
|
||||
|
||||
But it leads to an error. Why?
|
||||
|
||||
Fix the highlighted line for everything to start working right (other lines are not to be changed).
|
||||
|
||||
```js run
|
||||
function askPassword(ok, fail) {
|
||||
let password = prompt("Password?", '');
|
||||
if (password == "rockstar") ok();
|
||||
else fail();
|
||||
}
|
||||
|
||||
let user = {
|
||||
name: 'John',
|
||||
|
||||
loginOk() {
|
||||
alert(`${this.name} logged in`);
|
||||
},
|
||||
|
||||
loginFail() {
|
||||
alert(`${this.name} failed to log in`);
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
*!*
|
||||
askPassword(user.loginOk, user.loginFail);
|
||||
*/!*
|
||||
```
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue