From d58f79bff27df14ad6f79e4f386dc724c79eaf14 Mon Sep 17 00:00:00 2001 From: Kyle Easton Date: Wed, 29 Nov 2017 18:15:56 -0800 Subject: [PATCH 1/2] first go at homework 11/29/17 --- challenges/bottles-of-beer-song.js | 15 +++++++++++++++ challenges/palindrome-detector.js | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/challenges/bottles-of-beer-song.js b/challenges/bottles-of-beer-song.js index 8dbd822..1812c85 100644 --- a/challenges/bottles-of-beer-song.js +++ b/challenges/bottles-of-beer-song.js @@ -22,3 +22,18 @@ */ // YOUR CODE HERE + +let question = prompt("How many verses do you want to hear?", "Enter a number less than 100"); + + +for (var i = question; i >= 0; i -=1) { + if (i > 2) { + console.log(i + " bottles of beer on the wall, " + i + " bottles of beer! Take one down, pass it around, " + (i-1) + " bottles of beer on the wall!"); +} else if (i ===2) { + console.log(i + " bottles of beer on the wall, " + i + " bottles of beer! Take one down, pass it around, " + (i-1) + " bottle of beer on the wall!"); +} else if (i === 1) { + console.log(i + " bottle of beer on the wall, " + i + " bottle of beer! Take one down, pass it around, no more bottles of beer on the wall!"); +} else if (i === 0) { + console.log(i + " bottles of beer on the wall, " + i + " bottles of beer! None to take down, none to pass it around, no more bottles of beer on the wall!"); +} +} \ No newline at end of file diff --git a/challenges/palindrome-detector.js b/challenges/palindrome-detector.js index 86e0a62..40afb09 100644 --- a/challenges/palindrome-detector.js +++ b/challenges/palindrome-detector.js @@ -21,3 +21,21 @@ */ // YOUR CODE HERE + +var isPalindrome = function (word) { + let arrayOfLetters = word.split(""); + for (let i = 0; i <= arrayOfLetters.length; i++) { + if(arrayOfLetters[i] === arrayOfLetters[(arrayOfLetters.length - (i + 1))]) { + console.log(true); + } else { + console.log(false); + } + } + +} + +isPalindrome("apple"); + + + + From aaccdb2e4e21be36fab96ed95321763e12bf7b43 Mon Sep 17 00:00:00 2001 From: Kyle Easton Date: Thu, 30 Nov 2017 00:40:37 -0800 Subject: [PATCH 2/2] Homework 11/29/17 --- challenges/index.html | 14 ++++++++++++ challenges/palindrome-detector.js | 2 +- challenges/primes.js | 22 ++++++++++++++++++ challenges/shakespearian-insult-generator.js | 24 ++++++++++++++++++++ challenges/style.css | 11 +++++++++ 5 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 challenges/index.html create mode 100644 challenges/style.css diff --git a/challenges/index.html b/challenges/index.html new file mode 100644 index 0000000..aa0f55c --- /dev/null +++ b/challenges/index.html @@ -0,0 +1,14 @@ + + + + Insult Maker + + + +
+

What is the insult?

+
+ + + + \ No newline at end of file diff --git a/challenges/palindrome-detector.js b/challenges/palindrome-detector.js index 40afb09..42f1c24 100644 --- a/challenges/palindrome-detector.js +++ b/challenges/palindrome-detector.js @@ -34,7 +34,7 @@ var isPalindrome = function (word) { } -isPalindrome("apple"); +isPalindrome("mom"); diff --git a/challenges/primes.js b/challenges/primes.js index d95fd9e..13d8a8d 100644 --- a/challenges/primes.js +++ b/challenges/primes.js @@ -10,3 +10,25 @@ */ // YOUR CODE HERE + +//1. + +let isPrime = function(num) { + if (num === 2 || num % 2 === 1) { + console.log(true); + } else { + console.log(false); + } +} + +//2. + +let primes = function(max) { + let primeArray = []; + for (let i = 2; i <= max; i++) { + if (i === 2 || i % 2 === 1) { + primeArray.push(i); + } + } + console.log(primeArray); +} diff --git a/challenges/shakespearian-insult-generator.js b/challenges/shakespearian-insult-generator.js index 15b79f0..3d29db6 100644 --- a/challenges/shakespearian-insult-generator.js +++ b/challenges/shakespearian-insult-generator.js @@ -17,3 +17,27 @@ 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 + + +let generateInsult = function() { +var result; +let randOne = first_word[(Math.random() * first_word.length) | 0]; +let randTwo = second_word[(Math.random() * second_word.length) | 0]; +let randThree = third_word[(Math.random() * third_word.length) | 0]; + +let askName = prompt("Who is this scoundrel that needs insulting?", "Enter a name"); +let numOfInsults = prompt("How many insults to give?", "Enter a number up to 3"); + if(numOfInsults === "1") { + result = askName + ", you are " + randOne + "!"; + } else if (numOfInsults === "2") { + result = askName + ", you are " + randOne + " and " + randTwo + "!"; + } else if (numOfInsults === "3") { + result = askName + ", you are a " + randOne + ", " + randTwo + " " + randThree + "!"; + } + console.log(result); + document.getElementsByTagName('h1')[0].innerHTML = result; +} + +generateInsult(); + + diff --git a/challenges/style.css b/challenges/style.css new file mode 100644 index 0000000..e689630 --- /dev/null +++ b/challenges/style.css @@ -0,0 +1,11 @@ +h1 { + color: red; + font-family: arial; + text-align: center; + border: 10px solid powderblue; + padding: 40px; + letter-spacing: 1px; + font-weight: 400; + font-size: 40px; + margin: 50px 50px; +} \ No newline at end of file