-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab-2.html
More file actions
117 lines (106 loc) · 3.95 KB
/
Copy pathlab-2.html
File metadata and controls
117 lines (106 loc) · 3.95 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html>
<head>
<style>
/* Add some basic CSS for styling */
body {
font-family: Arial, sans-serif;
text-align: center;
}
</style>
</head>
<body>
<h1>Welcome to My About Me Page</h1>
<!-- Ask the user for their name using a prompt -->
<script>
const userName = prompt("Greetings, and welcome to my webpage. What name do you prefer to be called?");
alert(`Alright, ${userName}! Let's play a guessing game about me.`);
// Define your biography, education, job experience, and goals
const biography = "I am obsessed with cotton candy, as bad as you need to breathe.";
const education = "I went graduated from Lewis and Clark community college and also played basketball for the women's team.";
const jobExperience = "I have served in the Army as a 92F, active duty and guard.";
const goals = "My goal is to become a full-stack developer and build amazing web applications.";
// Define the questions and answers
const questions = [
"Do I enjoy coding? (yes/no)",
"Do I have a degree in Computer Science? (yes/no)",
"Have I worked as a software engineer for 3 years? (yes/no)",
"Is my goal to become a full-stack developer? (yes/no)",
"Is my favorite color blue? (yes/no)",
"Guess a number between 1 and 10.",
"Name one of my favorite programming languages."
];
const answers = ["yes", "no", "no", "yes", "no", 7, ["JavaScript", "Python", "Java"]];
// Start the game
let score = 0;
for (let i = 0; i < questions.length; i++) {
if (i === 5) {
let attempts = 4;
let correctNumber = answers[i];
while (attempts > 0) {
const userGuess = parseInt(prompt(questions[i]));
if (userGuess === correctNumber) {
alert("Correct!");
score++;
break;
} else if (userGuess < correctNumber) {
alert("Too low! Try again.");
} else {
alert("Too high! Try again.");
}
attempts--;
}
if (attempts === 0) {
alert(`Out of attempts. The correct answer was ${correctNumber}.`);
}
} else if (i === 6) {
let attempts = 6;
const possibleAnswers = answers[i];
while (attempts > 0) {
const userAnswer = prompt(questions[i]);
if (possibleAnswers.includes(userAnswer)) {
alert("Correct!");
score++;
break;
} else {
alert(`Incorrect. You have ${attempts - 1} attempts remaining.`);
}
attempts--;
}
if (attempts === 0) {
alert(`Out of attempts. Possible answers: ${possibleAnswers.join(", ")}`);
}
} else {
let userAnswer = prompt(questions[i]).toLowerCase(); // Normalize user input to lowercase
if (userAnswer === answers[i]) {
alert("Correct!");
score++;
} else {
alert("Incorrect!");
}
}
}
// Display the user's name and the final score in the message
alert(`Thanks for playing, ${userName}! You got ${score} out of 7 questions correct.\n\nHere's some information about me:\n\n${biography}\n\n${education}\n\n${jobExperience}\n\n${goals}`);
</script>
<p>I am obsessed with cotton candy, as bad as you need to breathe.
I went graduated from Lewis and Clark community college and also played basketball for the women's team.
I have served in the Army as a 92F, active duty and guard
I have served in the Army as a 92F, active duty and guard.
My goal is to become a full-stack developer and build amazing web applications.
</p>
<h2>Top Ten Cars</h2>
<ol>
<li>BMW i4</li>
<li>Chevrolet Corvette</li>
<li>Honda Civic</li>
<li>Toyota GR Supra</li>
<li>Jeep Trackhawk</li>
<li>Dodge Challenger SRT</li>
<li>BMW i7</li>
<li>BMW X7</li>
<li>Lexus RX Hybrid</li>
<li>Mercedes-AMG SL43</li>
</ol>
</body>
</html>