-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathletter.js
32 lines (30 loc) · 872 Bytes
/
letter.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
// "displayLet" will show an underscore or letter. This function will check the letters guessed and will display the letter
function Letter(alpha) {
this.alpha = alpha; // alphabet
this.guessed = false; // letter guessed
// function to display wether or not letters were guessed correctly
this.displayLet = function() {
if (this.alpha === " ") {
return " ";
}
else if(!this.guessed) {
return "_";
}
else {
return this.alpha.toString();
}
}
// function to check input
this.check = function(userGuess) {
if(this.guessed) {
this.guessed = true;
}
else if (userGuess === this.alpha) {
this.guessed = true;
}else {
this.guessed = false;
}
return;
}
}
module.exports = Letter;