Skip to content

week 1 day 4 homework #17

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions challenges/bottles-of-beer-song.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,23 @@
*/

// YOUR CODE HERE

function song (numBottle) {
var bottles = "bottles"
while (numBottles > 0){
console.log(numBottles + " " + bottles + " of beer on the wall,");
console.log(numBottles + " " + bottles + " of beer!");
console.log("Take one down and pass it around,");
numBottles = numBottles - 1;
if (numBottles === 1) {
bottles = "bottle"
}
if (numBottles === 0) {
console.log("No more bottles of beer on the wall!");
} else {
console.log(numBottles + " " + " of beer on the wall!");
}
}
}

beer (1);
13 changes: 13 additions & 0 deletions challenges/palindrome-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,16 @@
*/

// YOUR CODE HERE




function isPalindrome(word) {
var array = string.split('');
for (var i = 0; i < string.length / 2; i++) {
if (string.charAt(i) !== string.charAt(string.length - 1 - i)) {
return false;
}
}
return true;
}
20 changes: 20 additions & 0 deletions challenges/primes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,23 @@
*/

// YOUR CODE HERE


function isPrime(num) {
for(var i = 2; i < num; i++) {
if(num % i === 0) {
return false;
}
}
return num > 1;
}

function primes(max) {
var primesList = [];
for (var i = 0; i <= max; i++) {
if (isPrime(i)) {
primesList.push(i);
}
}
return primesList;
}
11 changes: 11 additions & 0 deletions challenges/shakespearian-insult-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,14 @@ 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

var firstInsult = first_word[Math.floor(Math.random()*first_word.length)];
var secondInsult = second_word[Math.floor(Math.random()*second_word.length)];
var thirdInsult = third_word[Math.floor(Math.random()*third_word.length)];

function generateInsult () {
var firstInsult = first_word[Math.floor(Math.random()*first_word.length)];
var secondInsult = second_word[Math.floor(Math.random()*second_word.length)];
var thirdInsult = third_word[Math.floor(Math.random()*third_word.length)];
console.log(name + firstInsult + " " + secondInsult + " " + thirdInsult);
}
30 changes: 30 additions & 0 deletions challenges/shakespearian-insult-generatorTHISWORKS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Shakesperian Insult Generator

You saucy, fly-bitten, minnow, you! Randomly generate some zingers using the supplied list of words!

Bonuses:
- Encapsulate your logic in a `generateInsult` function
- Randomly generate 1 word, 2 word, and n word insults.
- Generate any number of insults, depending on a user supplied integer. (e.g. generateInsults(3) )
- Allow the user to supply a proper name as an input. ("Why Justin, you villainous toad-spotted strumpet!").
- Create a browser interface, using some combination of `prompt`, `alert`, and/or DOM manipulation.

*/

var first_word = ["yeasty", "weedy", "wayward", "warped", "villainous", "venomed", "vain", "unmuzzled", "tottering", "surly", "spongy", "spleeny", "saucy", "ruttish", "roguish", "reeky", "rank", "qualling", "puny", "puking", "pribbling", "paunchy", "mewling", "mangled", "mammering", "lumpish", "loggerheaded", "jarring", "infectious", "impertinent", "gorbellied", "goatish", "gleeking", "frothy", "froward", "fobbing", "fawning", "errant", "droning", "dissembling", "dankish", "currish", "craven", "clouted", "cockered", "churlish", "bootless", "beslubbering", "bawdy", "artless"];
var second_word = ["weather-bitten", "unchin-snouted", "toad-spotted", "tickle-brained", "tardy-gaited", "swag-bellied", "spur-galled", "sheep-biting", "shard-borne", "rump-fed", "rude-growing", "rough-hewn", "reeling-ripe", "pox-marked", "pottle-deep", "plume-plucked", "onion-eyed", "motley-minded", "milk-livered", "knotty-pated", "ill-nurtured", "ill-breeding", "idle-headed", "hell-hated", "hedge-born", "hasty-witted", "half-faced", "guts-griping", "full-gorged", "fool-born", "folly-fallen", "fly-bitten", "flap-mouthed", "fen-sucked", "fat-kidneyed", "elf-skinned", "earth-vexing", "dread-bolted", "doghearted", "dizzy-eyed", "dismal-dreaming", "crook-pated", "common-kissing", "clay-brained", "clapper-clawed", "boil-brained", "beetle-headed", "beef-witted", "bat-fowling", "base-court"];
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

var firstInsult = first_word[Math.floor(Math.random()*first_word.length)];
var secondInsult = second_word[Math.floor(Math.random()*second_word.length)];
var thirdInsult = third_word[Math.floor(Math.random()*third_word.length)];

function generateInsult () {
var firstInsult = first_word[Math.floor(Math.random()*first_word.length)];
var secondInsult = second_word[Math.floor(Math.random()*second_word.length)];
var thirdInsult = third_word[Math.floor(Math.random()*third_word.length)];
console.log("You"+ " " + firstInsult + " " + secondInsult + " " + thirdInsult + "!");
}