forked from wdi-sg/table-flip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
39 lines (31 loc) · 1.13 KB
/
script.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
console.log("hello script js");
var secretWord = ["c","a","t"];
var emptyHangMan = [];
var hangMan = ['(','╯','ರ','~','ರ',')','╯','︵','┻━┻'];
var wordLeft;
var inputHappened = function(currentInput){
console.log( currentInput );
for (var i = 0; i < secretWord.length; i++) {
if(currentInput === secretWord[i] && secretWord.length > 1) {
secretWord.splice(i,1);
console.log("secretWord left: " + secretWord);
var wordLeft = secretWord.length;
console.log('wordLeft is ' + wordLeft)
return "One word down, " + wordLeft + " to go!";
} else if (currentInput === secretWord[i] && secretWord.length <= 1) {
secretWord.splice(i,1);
return "You win!";
}
}
if(currentInput !== 'c' || currentInput !== 'a' || currentInput !== 't' && emptyHangMan.length < 9){
emptyHangMan.unshift(hangMan.pop());
return emptyHangMan;
} else if( currentInput !== 'c' || currentInput !== 'a' || currentInput !== 't' && emptyHangMan.length === 9 ){
return emptyHangMan + " You lose";
}
}
/*var i = 0;
while (i > 0) {
console.log ("i is " + "i");
i++;
}*/