Project 1

This commit is contained in:
Karan 2021-11-24 22:15:47 +05:30 committed by GitHub
parent 8bccfa9c3a
commit 8528321836
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

33
Chapter 13/Project 1 Normal file
View 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");