Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,50 @@
// random word generator
var generateRandomWord = function () {
var randomDecimal = Math.random() * 3;
var randomInteger = Math.floor(randomDecimal) + 1;

var randomWord = 0;

if (randomInteger == 1) {
randomWord = "banana";
}

if (randomInteger == 2) {
randomWord = "chisel";
}

if (randomInteger == 3) {
randomWord = "faucet";
}

return randomWord;
};

var winCount = 0;

var main = function (input) {
var myOutputValue = 'hello world';
return myOutputValue;
// var secretWord = generateRandomWord();
var secretWord = "banana";
console.log("Secret word: ", secretWord);

var myOutputValue =
"You lose! You need to guess the secret word twice in a row to win.";

if (winCount == 1 && input != secretWord) {
winCount = 0;
}

if (input == secretWord) {
winCount += 1;
myOutputValue =
"You managed to guess the secret word! Lucky? Guess it right again to win the game!";
}

if (winCount == 2) {
myOutputValue = "Wow, you guessed it twice in a row! You win!";
winCount = 0;
}

console.log("Win count: ", winCount);
return `You guessed ${input}. The secret word was ${secretWord}. ${myOutputValue}`;
};