forked from rocketacademy/basics-github-practice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (32 loc) · 909 Bytes
/
script.js
File metadata and controls
37 lines (32 loc) · 909 Bytes
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
var randomNum = function () {
var randomDecimal = Math.random() * 3;
var randomInteger = Math.floor(randomDecimal);
return randomInteger;
};
var pegNumToWord = function () {
var comNum = randomNum();
if (comNum == 0) {
return "banana";
}
if (comNum == 1) {
return "chisel";
}
if (comNum == 2) {
return "faucet";
}
};
var winCounter = 0;
var main = function (input) {
var comWord = pegNumToWord();
if (input == comWord && winCounter == 1) {
winCounter += 1;
return `you have selected ${input}, the secret word is ${comWord}. you have 2 correct guesses. YOU WIN!`;
}
if (input == comWord) {
winCounter += 1;
return `you have selected ${input}, the secret word is ${comWord}. one more right guess to win!`;
}
if (input != comWord) {
return `you have selected ${input}, the secret word is ${comWord}. you have got it wrong! try again.`;
}
};