From 13a7db28a5719a47d77db7904f74551d69431e59 Mon Sep 17 00:00:00 2001 From: AdamMenard Date: Thu, 30 Nov 2017 08:35:59 -0800 Subject: [PATCH 1/2] Progress in homework Nov30 --- challenges/bottles-of-beer-song.js | 20 ++++++++++++++++++++ challenges/primes.js | 18 ++++++++++++++++++ challenges/shakespearian-insult-generator.js | 8 ++++++++ 3 files changed, 46 insertions(+) diff --git a/challenges/bottles-of-beer-song.js b/challenges/bottles-of-beer-song.js index 8dbd822..3b6591b 100644 --- a/challenges/bottles-of-beer-song.js +++ b/challenges/bottles-of-beer-song.js @@ -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! :("); + } + } +}; diff --git a/challenges/primes.js b/challenges/primes.js index d95fd9e..d5eec4b 100644 --- a/challenges/primes.js +++ b/challenges/primes.js @@ -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; +}; diff --git a/challenges/shakespearian-insult-generator.js b/challenges/shakespearian-insult-generator.js index 15b79f0..d0ae3a4 100644 --- a/challenges/shakespearian-insult-generator.js +++ b/challenges/shakespearian-insult-generator.js @@ -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!"); +}; From adbd4afd48d75adedadc259456a204d165894006 Mon Sep 17 00:00:00 2001 From: AdamMenard Date: Thu, 30 Nov 2017 08:44:57 -0800 Subject: [PATCH 2/2] palindome update --- challenges/palindrome-detector.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/challenges/palindrome-detector.js b/challenges/palindrome-detector.js index 86e0a62..bff29cf 100644 --- a/challenges/palindrome-detector.js +++ b/challenges/palindrome-detector.js @@ -21,3 +21,7 @@ */ // YOUR CODE HERE + +function isPalindrome(input) { + return (input.split('').reverse().join('') === input); +};