Device Sync
This commit is contained in:
@@ -1,61 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lab 3</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Lab 3</h1>
|
||||
<script>
|
||||
/*
|
||||
* I have decided to declare my fortune messages in order of
|
||||
* most-to-least positive
|
||||
*/
|
||||
var fortune1 = "You will have a great day";
|
||||
var fortune2 = "Success if around the corner";
|
||||
var fortune3 = "Happiness comes from within";
|
||||
var fortune4 = "Today will be okay";
|
||||
var fortune5 = "Keep an eye on the details";
|
||||
var fortune6 = "Patience will be tested";
|
||||
var fortune7 = "You will step on LEGO soon";
|
||||
var fortune8 = "Beware of pigeons, they have attitude";
|
||||
var fortune9 = "Your WIFI will mysteriously stop working";
|
||||
|
||||
// Prompt user for numCookies
|
||||
var numCookies = window.prompt("How many cookies do you want to open?");
|
||||
|
||||
// Loop starting at 1, stoping at numCookies
|
||||
for (var i = 1; i <=numCookies; i++) {
|
||||
|
||||
// Generate random number from 1 - 9 inclusive
|
||||
var randNum = Math.floor(Math.random() * 9) + 1;
|
||||
|
||||
// Assign messge and cateogry to blank for now
|
||||
var message = ""
|
||||
var category = ""
|
||||
|
||||
// Determine message and category from randNum
|
||||
if (randNum <= 3) {
|
||||
if (randNum === 1) message = fortune1;
|
||||
else if (randNum === 2) message = fortune2;
|
||||
else message = fortune3;
|
||||
category = "Positive"; // Positive if 1-3
|
||||
} else if (randNum <= 6) {
|
||||
if (randNum === 4) message = fortune4;
|
||||
else if (randNum === 5) message = fortune5;
|
||||
else message = fortune6;
|
||||
category = "Neutral"; // Neutral if 4-6
|
||||
} else {
|
||||
if (randNum === 7) message = fortune7;
|
||||
else if (randNum === 8) message = fortune8;
|
||||
else message = fortune9;
|
||||
category = "Funny" // Funny if 7-9
|
||||
}
|
||||
|
||||
// Display fortune cookie details
|
||||
console.log("Cookie #" + i + "\nMessage: " + message + "\nCategory: " + category);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lab 3</title>
|
||||
<meta charset="UTF-8">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Lab 3</h1>
|
||||
<script>
|
||||
/*
|
||||
* I have decided to declare my fortune messages in order of
|
||||
* most-to-least positive
|
||||
*/
|
||||
var fortune1 = "You will have a great day";
|
||||
var fortune2 = "Success if around the corner";
|
||||
var fortune3 = "Happiness comes from within";
|
||||
var fortune4 = "Today will be okay";
|
||||
var fortune5 = "Keep an eye on the details";
|
||||
var fortune6 = "Patience will be tested";
|
||||
var fortune7 = "You will step on LEGO soon";
|
||||
var fortune8 = "Beware of pigeons, they have attitude";
|
||||
var fortune9 = "Your WIFI will mysteriously stop working";
|
||||
|
||||
// Prompt user for numCookies
|
||||
var numCookies = window.prompt("How many cookies do you want to open?");
|
||||
|
||||
// Loop starting at 1, stoping at numCookies
|
||||
for (var i = 1; i <=numCookies; i++) {
|
||||
|
||||
// Generate random number from 1 - 9 inclusive
|
||||
var randNum = Math.floor(Math.random() * 9) + 1;
|
||||
|
||||
// Assign messge and cateogry to blank for now
|
||||
var message = ""
|
||||
var category = ""
|
||||
|
||||
// Determine message and category from randNum
|
||||
if (randNum <= 3) {
|
||||
if (randNum === 1) message = fortune1;
|
||||
else if (randNum === 2) message = fortune2;
|
||||
else message = fortune3;
|
||||
category = "Positive"; // Positive if 1-3
|
||||
} else if (randNum <= 6) {
|
||||
if (randNum === 4) message = fortune4;
|
||||
else if (randNum === 5) message = fortune5;
|
||||
else message = fortune6;
|
||||
category = "Neutral"; // Neutral if 4-6
|
||||
} else {
|
||||
if (randNum === 7) message = fortune7;
|
||||
else if (randNum === 8) message = fortune8;
|
||||
else message = fortune9;
|
||||
category = "Funny" // Funny if 7-9
|
||||
}
|
||||
|
||||
// Display fortune cookie details
|
||||
console.log("Cookie #" + i + "\nMessage: " + message + "\nCategory: " + category);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user