-
Notifications
You must be signed in to change notification settings - Fork 3
/
usersearch.js
47 lines (43 loc) · 1.16 KB
/
usersearch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
var search = {};
const users = [
{
"email":"[email protected]",
"password":"12345678"
},
{
"email":"[email protected]",
"password":"abcdefgh"
}
]
search.user = function SearchUser(email, password) {
let user = {
"email" : `${email}`,
"password" : `${password}`
}
let userfound = false;
for (let i = 0; i < users.length; i++) {
let emailmatched = users[i].email === user.email
let passwordmatched = users[i].password === user.password
// console.log(i)
if (emailmatched && passwordmatched) {
console.log('User found!!!')
userfound = true;
break;
}
else if(!emailmatched && !passwordmatched){
// console.log("Searching")
break
}
else if (emailmatched && !passwordmatched){
console.log('Password incorrect')
}
}
if (userfound) {
console.log("login sucessful")
}
// else {
// console.log("Password or email incorrect!")
// }
}
// SearchUser("[email protected]","12345678")
exports.data = search