diff --git a/script.js b/script.js
index bbe8a29..5575c67 100644
--- a/script.js
+++ b/script.js
@@ -1,4 +1,41 @@
+var winCounter = 0;
+var roundCounter = 1;
+
var main = function (input) {
- var myOutputValue = 'hello world';
+ var secretWord = randomWord();
+
+ var myOutputValue = `Round ${roundCounter}
You guessed ${input}. The secret word was ${secretWord}.`;
+ myOutputValue += `
Sorry you picked the wrong word. You have guessed correctly ${winCounter} time(s).
${
+ 2 - winCounter
+ } more to go!`;
+
+ if (input == secretWord) {
+ winCounter = winCounter + 1;
+ myOutputValue = `Round ${roundCounter}
You guessed ${input}. The secret word was ${secretWord}.`;
+ myOutputValue += `
That's right! You have guessed correctly ${winCounter} time(s).
${
+ 2 - winCounter
+ } more to go!`;
+ if (winCounter == 2) {
+ myOutputValue = `Round ${roundCounter}
You guessed ${input}. The secret word was ${secretWord}.`;
+ myOutputValue += `
That's right!
You've won this round! Let's start a new round...`;
+ roundCounter = roundCounter + 1;
+ winCounter = 0;
+ }
+ }
return myOutputValue;
};
+
+var randomWord = function () {
+ var randomDecimal = Math.random() * 3;
+ var randomInteger = Math.floor(randomDecimal);
+ if (randomInteger == 0) {
+ var secret = "banana";
+ }
+ if (randomInteger == 1) {
+ var secret = "chisel";
+ }
+ if (randomInteger == 2) {
+ var secret = "faucet";
+ }
+ return secret;
+};