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
32 changes: 30 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
var correctGuess = 0;
var banana = "banana";
var chisel = "chisel";
var faucet = "faucet";

var randomWords = function () {
var random = Math.ceil(Math.random() * 3);
if (random == 1) return banana;
if (random == 2) return chisel;
if (random == 3) return faucet;
};

var message = function (guess, secret, correct) {
return `The guessed word is ${guess} and the secret word is ${secret}. <br><br> You have guessed ${correct} secret word(s) correctly.`;
};

var main = function (input) {
var myOutputValue = 'hello world';
return myOutputValue;
computer = randomWords();

if (input == "") return "Please enter banana, chisel or faucet";
if (correctGuess == 2) {
correctGuess = 0;
}
if (input == computer) {
correctGuess += 1;
}
if (input == computer && correctGuess == 2) {
return "You win!" + "<br><br>" + message(input, computer, correctGuess);
}

return message(input, computer, correctGuess);
};