Skip to content
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

HW submission for Nov30 JS basics #22

Open
wants to merge 2 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 bottlesOfBeer(n) {
for (var i = n; i > 0; i--) {
if (i > 1) {
console.log(i + " bottles of beer on the wall,");
console.log(i + " bottles of beer!");
console.log("Take one down and pass it around,");
if (i-1 === 1) {
console.log("One bottle of beer on the wall...");
} else {
console.log((i-1) + " bottles of beer on the wall...");
}
} else if (i === 1) {
console.log("One bottle of beer on the wall,");
console.log("One bottle of beer!");
console.log("Take it down and pass it around,");
console.log("No more bottles of beer on the wall! :(");
}
}
};
4 changes: 4 additions & 0 deletions challenges/palindrome-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@
*/

// YOUR CODE HERE

function isPalindrome(input) {
return (input.split('').reverse().join('') === input);
};
18 changes: 18 additions & 0 deletions challenges/primes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,21 @@
*/

// YOUR CODE HERE

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

function primes(max) {
let primesArray = [];

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


function insultGen() {
let one = first_word[parseInt(Math.random() * first_word.length)];
let two = second_word[parseInt(Math.random() * second_word.length)];
let three = third_word[parseInt(Math.random() * third_word.length)];
return ()"You " + one + ", " + two + ", " + three + "you!");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused about your parentheses on this line, but otherwise this code looks good!

Copy link
Author

@AdamMenard AdamMenard Dec 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the extra parentheses now, Thanks for catching it!

};