-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
68 lines (51 loc) · 1.52 KB
/
Copy pathapp.js
File metadata and controls
68 lines (51 loc) · 1.52 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
console.log ("Our proof of LIFE!");
let userName = "Beardy";
console.log(userName);
function askTheUser() {
var myName = prompt("What shall I call you?");
console.log("myName: ", myName);
}
if (myName == 'Jason') {
document.write('Welcome to the Gallery of Beards, ' + myName);
} else {
document.write("Welcome, " + myName);
}
let myAge = 25;
console.log(typeof myAge);
function picksNumbers() {
let num1 = prompt("pick a number")
return num1;
}
function displayRating() {
let output = "";
let rating = prompt('how many stars?');
for (let i = 0; i < rating; i++) {
output += "⭐"
}
return document.write(output);
}
// while loop
// creating user guessing game
function guessingGame() {
let userGuess = prompt("What is my favorite color?");
let correctAnswer = Blue;
let attempts = 4;
for (let i = 0; i < attempts; i++) {
while (userGuess < 1 || userGuess > 100) {
userGuess = prompt("Please try again...! A number between 1 and 100");
}
if (userGuess == correctAnswer) {
alert('How did you know?!!');
document.write("Game Winner!");
break;
} else if (userGuess > correctAnswer) {
userGuess = prompt("Sorry, I don't like that one!! Please guess another...");
} else if (userGuess < correctAnswer) {
userGuess = prompt("Sorry, that's wrong...");
}
if (i == 3) {
alert("The correct answer was " + correctAnswer);
document.write("Game Loser!");
}
}
}