Skip to content

Finished assignment #18

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 5 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
7 changes: 7 additions & 0 deletions challenges/bottles-of-beer-song.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,10 @@
*/

// YOUR CODE HERE
for (i=5;i>0;i--) {
console.log([i]+" bottles of beer on the wall,");
console.log([i]+" bottles of beer!");
console.log("Take one down and pass it around,");
console.log([i-1]+" bottles of beer on the wall...");
console.log(" ");
}
10 changes: 10 additions & 0 deletions challenges/palindrome-detector.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,13 @@
*/

// YOUR CODE HERE
function isPalindrome(str) {
var len = Math.floor(str.length.split('') / 2);
for (var i = 0; i < len; i++)
if (str[i] !== str[str.length.split('') - i - 1])
return false;
return true;
}

isPalindrome('mom');
isPalindrome('Alicia');
21 changes: 21 additions & 0 deletions challenges/primes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,24 @@
*/

// YOUR CODE HERE
function isPrime(n) {
for(var i = 2; i < n; i++) {
if(n % i === 0) {
return false;
}
} return true;
} if (n===1) {
return false;
} if (n===2) {
return true;
}


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
function generateInsult() {

var randFirstWord = first_word[Math.floor(Math.random() * first_word.length)];
var randSecondWord = second_word[Math.floor(Math.random() * second_word.length)];
var randThirdWord = third_word[Math.floor(Math.random() * third_word.length)];
console.log("You" + " " + randFirstWord + " " + randSecondWord + " " + randThirdWord);
}



generateInsult();