still working on day 4 exercises

pull/862/head
Dzykas 3 years ago
parent 4eb9ca2eb6
commit 8556d9ba3f

@ -7,7 +7,7 @@
<body style="background-color: black; color: white;">
<style>
button{
button {
color: white;
background-color: black;
padding: 5px;
@ -19,8 +19,13 @@
<h2>Conditionals</h2>
<script src="main.js"></script>
<script src="level2.js"></script>
<button onclick="canDrive()">Are you old enough to drive ?</button><br>
<button onclick="isOlder()">Are you older than me ?</button><br>
<button onclick="isEven()">Is this number even or odd ?</button><br>
<button onclick="grades()">What grade did you get ?</button><br>
<button onclick="whatSeason()">What season is it ?</button><br>
<button onclick="isWeekend()">Is it the weekend ?</button><br>
</body>

@ -1 +1,57 @@
console.log("a")
function grades() {
let score = parseInt(prompt("What is your score ?"));
switch (true) {
case (score >= 80 && score <= 100):
alert(`A score of ${score} gets you an A!`);
break;
case (score >= 70 && score <= 79):
alert(`A score of ${score} gets you a B!`);
break;
case (score >= 60 && score <= 69):
alert(`A score of ${score} gets you a C!`);
break;
case (score >= 50 && score <= 59):
alert(`A score of ${score} gets you a D!`);
break;
default:
alert(`A score of ${score} gets you an F!`)
}
}
function whatSeason() {
let month = prompt("What month is it?").toLowerCase();
if (month === "september" || month === "october" || month === "november") {
alert("The current season is Autumn!");
}
else if (month === "december" || month === "january" || month === "february") {
alert("The current season is Winter!");
}
else if (month === "march" || month === "april" || month === "may") {
alert("The current season is Spring!");
}
else if (month === "june" || month === "july" || month === "august") {
alert("The current season is Summer!");
}
else {
alert("ignas.");
}
}
function isWeekend() {
let day = prompt("What day is it ?").toLowerCase()
switch (day) {
case "monday":
case "tuesday":
case "wednesday":
case "thursday":
case "friday":
alert(`${day} is a working day.`);
break;
case "saturday":
case "sunday":
alert(`${day} is a weekend!`);
break;
default:
alert("ignas");
}
}

@ -37,4 +37,14 @@ switch (true) {
break;
default:
console.log(`${a} is less than ${b}`);
}
function isEven() {
num = parseInt(prompt("Input a number:"))
if (num % 2 === 0) {
alert(`${num} is an even number.`)
}
else {
alert(`${num} is an odd number.`)
}
}
Loading…
Cancel
Save