Skip to content

Commit d10542b

Browse files
committed
return exercise completed
1 parent 5b60bb1 commit d10542b

1 file changed

Lines changed: 58 additions & 8 deletions

File tree

‎Sprint-3/passwordCheckerFunction.js‎

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,71 @@
11
// Already have the password stored in a variable;
2-
const password = "Mattcarolus10";
2+
// Exercise one: Using console.log and calling function
3+
// const password = "Mattcarolus10";
4+
5+
// // Receive the value which the user entered;
6+
// function checkPassword(userInput) {
7+
8+
// // Compare the two values;
9+
// if (userInput===password) {
10+
11+
// // If they match print "Correct password entered";
12+
// console.log("Correct password entered ")
13+
// }
14+
15+
// else {
16+
// // If they don't match print "Incorrect password, please try again";
17+
// console.log("Incorrect password, please try again")
18+
// };
19+
20+
// };
21+
// checkPassword("Mattcarolus10");
22+
23+
24+
25+
// // Exercise 2: Using the variable scope "response"
26+
// const password2 = "Mattcarolus10";
27+
28+
// // Receive the value which the user entered;
29+
// function checkPassword(userInput) {
30+
31+
// // Compare the two values;
32+
// if (userInput===password2) {
33+
34+
// // If they match print "Correct password entered";
35+
// response = "Correct password entered "
36+
// }
37+
38+
// else {
39+
// // If they don't match print "Incorrect password, please try again";
40+
// response = "Incorrect password, please try again"
41+
// };
42+
43+
// };
44+
// checkPassword("Mattcarolus");
45+
// console.log(response)
46+
47+
48+
49+
const password3 = "Mattcarolus10";
50+
const output = checkPassword("Mattcarolus10");
351

452
// Receive the value which the user entered;
553
function checkPassword(userInput) {
54+
let response;
655

756
// Compare the two values;
8-
if (userInput===password) {
57+
if (userInput===password3) {
958

1059
// If they match print "Correct password entered";
11-
response = "Correct password entered "
60+
response = "Correct password entered ";
1261
}
1362

1463
else {
1564
// If they don't match print "Incorrect password, please try again";
16-
response = "Incorrect password, please try again"
17-
};
65+
response = "Incorrect password, please try again";
66+
}
67+
return response;
68+
}
69+
console.log(output);
70+
1871

19-
};
20-
checkPassword("Mattcarolus");
21-
console.log(response)

0 commit comments

Comments
 (0)