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
68 changes: 66 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,68 @@
var randomWinsNeeded = function () {
var randomDecimal = Math.random() * 3;
var randomInteger = Math.floor(randomDecimal) + 2;

return randomInteger;
};

var winsNeeded = randomWinsNeeded();
console.log("correct guesses to win=====", winsNeeded);

var randomWordGenerate = 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 = randomWordGenerate();
var secretWord = "banana";

var myOutputValue = `You need ${winsNeeded} correct guesses in a row to win`;

console.log("secret word ===", secretWord);

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

if (input == secretWord) {
winCount += 1;
console.log("curren correct guesses", winCount);
myOutputValue = `You have ${winCount} correct guesses. You need need ${
winsNeeded - winCount
} more correct guesses in a row to win`;
}

if (winCount == winsNeeded) {
myOutputValue = `You guess correctly ${winsNeeded} time. You win!`;
winCount = 0;
winsNeeded = randomWinsNeeded();
console.log("correct guesses to win in new round=====", winsNeeded);
}

return (
"You guessed " +
input +
". The secret word was " +
secretWord +
". " +
myOutputValue
);
};