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
58 changes: 57 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
// Function
var random_Number = function () {
var randomNumber = Math.random() * 3;
// range from 0 to 2
var integernumber = Math.floor(randomNumber);
// range from 2 to 4
var number = integernumber + 2;
return number;
};

var counter = 0;
var round = random_Number();
console.log(round);

var main = function (input) {
var myOutputValue = 'hello world';
var myOutputValue = "";

var computer_choice = secret_word();
console.log(computer_choice);

if (input == computer_choice) {
counter += 1;
myOutputValue = "You guessed it correctly " + counter + " time(s)";
} else {
counter = 0;
myOutputValue =
"You guessed it wrongly! " + counter + " time(s) correctly.";
}

if (counter == round) {
myOutputValue = `You win! You guessed it correctly ${counter} time(s)`;
}

return myOutputValue;
};

var rollRandom = function () {
var randomNumber = Math.random() * 3;
var integernumber = Math.floor(randomNumber);
var choices = integernumber + 1;
return choices;
};

var secret_word = function () {
var choice = rollRandom();
var word = "";

if (choice == 1) {
word = "banana";
}

if (choice == 2) {
word = "chisel";
}
if (choice == 3) {
word = "faucet";
}

return word;
};