Project 1
This commit is contained in:
parent
8bccfa9c3a
commit
8528321836
33
Chapter 13/Project 1
Normal file
33
Chapter 13/Project 1
Normal file
@ -0,0 +1,33 @@
|
||||
const allowed = ["1234", "pass", "apple"];
|
||||
|
||||
function passwordChecker(pass) {
|
||||
return allowed.includes(pass);
|
||||
}
|
||||
|
||||
function login(password) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (passwordChecker(password)) {
|
||||
resolve({
|
||||
status: true
|
||||
})
|
||||
} else {
|
||||
reject({
|
||||
status: false
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function checker(pass) {
|
||||
login(pass)
|
||||
.then(token => {
|
||||
console.log("Approve:");
|
||||
console.log(token)
|
||||
})
|
||||
.catch(value => {
|
||||
console.log("Reject:");
|
||||
console.log(value)
|
||||
})
|
||||
}
|
||||
checker("1234");
|
||||
checker("wrong");
|
||||
Loading…
x
Reference in New Issue
Block a user