-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomework2.html
More file actions
23 lines (23 loc) · 802 Bytes
/
homework2.html
File metadata and controls
23 lines (23 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!-- Write a program for a vending machine. The customer enters their name and age and gets a drink.
If the customer is under 21, the line “Take a glass of juice” is displayed; if the customer is 21
or older, the line “I can offer you a glass of wine” is displayed; if over 80, the line “Maybe some
tea?” is displayed. -->
<body>
<script>
const userName = prompt("What's your name?");
console.log(`Hello, ${userName}!`);
const userAge = Number(prompt("What's your age?"));
if (userAge < 21){
console.log("We can offer you a glass of juice!");
}
else if (userAge >= 21 && userAge < 80){
console.log("We can offer you a glass of wine!");
}
else if (userAge >= 80){
console.log("We can offer you a cup of tea!");
}
else{
console.log("We can offer you sweet nothing!");
}
</script>
</body>