Skip to content

Problem Set JS Basics #7

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

// YOUR CODE HERE

function bottles() {
for(var i=100 ; i>=01;i-=1) {
if(i===1){
console.log(i + " " + "bottle of beer on the wall" + ",");
console.log(i + " " + "bottle of beer!");
console.log("Take one down and pass it around,");
console.log("No more bottles of beer on the wall...");
}
else{
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(" ");
}
}
}
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(str){
str = str.toLowerCase();
return str == str.split('').reverse().join('');
}
17 changes: 17 additions & 0 deletions challenges/primes.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,20 @@
*/

// 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;
}
7 changes: 7 additions & 0 deletions challenges/shakespearian-insult-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ 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 rand = first_word[Math.floor(Math.random() * first_word.length)];
var rand2 = second_word[Math.floor(Math.random() * second_word.length)];
var rand3 = third_word[Math.floor(Math.random() * third_word.length)];

var generateInsult = function generateInsult(){
console.log("You" + " " + rand + "," + " " + rand2 + "," + " " + rand3 + "," + " " + "you!");
};