-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kyle Easton's Homework - 11/29/17 #20
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Insult Maker</title> | ||
<link rel="stylesheet" type="text/css" href="style.css"> | ||
</head> | ||
<body> | ||
<div> | ||
<h1>What is the insult?</h1> | ||
</div> | ||
|
||
</body> | ||
<script src="shakespearian-insult-generator.js"></script> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,25 @@ | |
*/ | ||
|
||
// YOUR CODE HERE | ||
|
||
//1. | ||
|
||
let isPrime = function(num) { | ||
if (num === 2 || num % 2 === 1) { | ||
console.log(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, here it would be better to |
||
} else { | ||
console.log(false); | ||
} | ||
} | ||
|
||
//2. | ||
|
||
let primes = function(max) { | ||
let primeArray = []; | ||
for (let i = 2; i <= max; i++) { | ||
if (i === 2 || i % 2 === 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this will add every odd number to your list of primes--remember to test on lots of interesting cases! |
||
primeArray.push(i); | ||
} | ||
} | ||
console.log(primeArray); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,27 @@ var second_word = ["weather-bitten", "unchin-snouted", "toad-spotted", "tickle-b | |
var third_word = ["wagtail", "whey-face", "vassal", "varlet", "strumpet", "skainsmate", "scut", "ratsbane", "pumpion", "puttock", "pignut", "pigeon-egg", "nut-hook", "mumble-news", "moldwarp", "miscreant", "minnow", "measle", "mammet", "malt-worm", "maggot-pie", "lout", "lewdster", "joithead", "hugger-mugger", "horn-beast", "hedge-pig", "harpy", "haggard", "gudgeon", "giglet", "fustilarian", "foot-licker", "flirt-gill", "flax-wench", "flap-dragon", "dewberry", "death-token", "codpiece", "coxcomb", "clotpole", "clack-dish", "canker-blossom", "bum-bailey", "bugbear", "boar-pig", "bladder", "barnacle", "baggage", "apple-john"]; | ||
|
||
// YOUR CODE HERE | ||
|
||
|
||
let generateInsult = function() { | ||
var result; | ||
let randOne = first_word[(Math.random() * first_word.length) | 0]; | ||
let randTwo = second_word[(Math.random() * second_word.length) | 0]; | ||
let randThree = third_word[(Math.random() * third_word.length) | 0]; | ||
|
||
let askName = prompt("Who is this scoundrel that needs insulting?", "Enter a name"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sense you needed to add the HTML page to get these prompts to work--nice job going beyond the directions to complete the bonus. |
||
let numOfInsults = prompt("How many insults to give?", "Enter a number up to 3"); | ||
if(numOfInsults === "1") { | ||
result = askName + ", you are " + randOne + "!"; | ||
} else if (numOfInsults === "2") { | ||
result = askName + ", you are " + randOne + " and " + randTwo + "!"; | ||
} else if (numOfInsults === "3") { | ||
result = askName + ", you are a " + randOne + ", " + randTwo + " " + randThree + "!"; | ||
} | ||
console.log(result); | ||
document.getElementsByTagName('h1')[0].innerHTML = result; | ||
} | ||
|
||
generateInsult(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
h1 { | ||
color: red; | ||
font-family: arial; | ||
text-align: center; | ||
border: 10px solid powderblue; | ||
padding: 40px; | ||
letter-spacing: 1px; | ||
font-weight: 400; | ||
font-size: 40px; | ||
margin: 50px 50px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we talk about functions more tomorrow & next week, we'll talk about why
console.log
is less useful here than usingreturn
, but it's good that you got this working!