-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbearHuman0rGun.js
More file actions
87 lines (80 loc) · 2.91 KB
/
bearHuman0rGun.js
File metadata and controls
87 lines (80 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Mini App: Bear, Human, super Soaka gun Game
// Bear human gun is just like Rock paper scissors
/*
Each player chooses either bear, human,super Soaka gun.
The items are compared, and whichever player chooses
the more powerful item wins.
*/
// // create function getUserChoice with a parameter of `userInput`
// function getUserChoice(userInput) {
// // turn future `userInput` to lower case
// userInput = userInput.toLowerCase();
// // if there is a match return `userInput`
// if (userInput === 'bear' || userInput === 'human' || userInput === 'gun') {
// return userInput;
// // if no match prompt user for valid entry
// } else {
// return 'Please enter valid option';
// }
// }
// // create a function that will provide a random computer choice for each round
// function getComputerChoice() {
// var randomNumber = Math.floor(Math.random() * 3);
// if (randomNumber === 0) {
// return 'bear';
// } else if (randomNumber === 1) {
// return 'human';
// } else {
// return 'gun';
// }
// }
// // create a function `determineWinner` and pass in parameters
// // `userChoice` and `computerChoice`
// function determineWinner(userChoice, computerChoice) {
// // if there is a tie
// if (userChoice === computerChoice) {
// return 'It is a tie';
// }
// // if user selects `'human'`
// if (userChoice === 'human') {
// // if computer selects `'bear'`
// if (computerChoice === 'bear') {
// return 'You have been mauled by a bear';
// } else {
// return 'You have disarmed a gun';
// }
// }
// // if user selects `'bear'`
// if (userChoice === 'bear') {
// // if computer selects `'gun'`
// if (computerChoice === 'gun') {
// return 'You have been shot by a gun';
// } else {
// return 'You have mauled a human';
// }
// }
// // if user selects `'gun'`
// if (userChoice === 'gun') {
// // if computer selectsion `'human'`
// if (computerChoice === 'human') {
// return 'Your gun has been disarmed';
// } else {
// return 'You have shot a bear';
// }
// }
// }
// function playGame() {
// // prompt user to make choice
// var promptUsesChoice = prompt("Please choose bear, human or gun");
// // format user choice to lower case and check for valid word
// var userChoice = getUserChoice(promptUsesChoice);
// // call `getComputerChoice()` and assign to variable `computerChoice`
// var computerChoice = getComputerChoice();
// console.log(computerChoice);
// console.log(userChoice);
// // pass `userChoice` and `computerChoice` to the function `determineWinner`
// // and log to the console
// console.log(determineWinner(userChoice, computerChoice));
// }
// // call `playGame` function
// playGame();