Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

word game #41

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
46 changes: 45 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,48 @@
var PassingMark = function () {
var randMark = Math.ceil(Math.random() * 3) + 1;
return randMark;
};
var Points = 0;
var WinCounter = PassingMark();
var WinCounter02 = WinCounter;
var main = function (input) {
var myOutputValue = 'hello world';
var ComputerWords = "a";
console.log(ComputerWords);
var myOutputValue = "Please continue guessing.";
if (ComputerWords == input && WinCounter == 1) {
return `Congratulations you guessed it right ${WinCounter02} times! The game will end.`;
}
if (ComputerWords != input) {
WinCounter = WinCounter + Points;
Points = 0;
myOutputValue = "Sorry! You're back to square one. Please try again.";
}
if (ComputerWords == input) {
WinCounter = WinCounter - 1;
Points = Points + 1;
myOutputValue = "Congratulations you guessed it right!";
}
console.log(`WinCounter ${WinCounter}.`);
console.log(`Points ${Points}`);
return myOutputValue;
};
//If the computer != players input & the score equals to one, player loses 1 point.
//Three secret words: banana, chisel and faucet.
//Player must guess correctly twice in total.
//Use dice roll to determine the computer choice.
var RollDice = function () {
var randNumber = Math.ceil(Math.random() * 3);
return randNumber;
};
var WordChoice = function () {
var Computerchoice = RollDice();
if (Computerchoice == 1) {
return "banana";
}
if (Computerchoice == 2) {
return "chisel";
}
if (Computerchoice == 3) {
return "faucet";
}
};