-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathword.js
38 lines (31 loc) · 1003 Bytes
/
word.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
var Letter = require('./letter.js');
function Word(word) {
this.constructWord = function(word) {
var temp = [];
for (var i = 0; i < word.length; i++) {
var currentChar = word[i];
var currentLetter = new Letter(currentChar);
temp.push(currentLetter);
}
return temp;
}
this.word = this.constructWord(word);
this.display = function() {
var displayWord = "";
for (var i = 0; i < this.word.length; i++) {
var currentLetter = this.word[i];
displayWord += currentLetter.display() + " ";
}
console.log(displayWord);
}
this.checkLetter = function(ltr) {
for (var i = 0; i < this.word.length; i++) {
var currentLetter = this.word[i];
console.log(currentLetter);
currentLetter.checkGuess(ltr);
}
return this.display;
}
}
// var word = new Word("Warriors");
module.exports = Word;