From a64786254ed3ca0aaa9229f99239ade54f7dcd54 Mon Sep 17 00:00:00 2001 From: tgrahams101 Date: Thu, 30 Jun 2016 20:35:06 -0700 Subject: [PATCH 1/4] finished bottles of beer problem --- challenges/bottles-of-beer-song.js | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/challenges/bottles-of-beer-song.js b/challenges/bottles-of-beer-song.js index 8dbd822..c752530 100644 --- a/challenges/bottles-of-beer-song.js +++ b/challenges/bottles-of-beer-song.js @@ -22,3 +22,48 @@ */ // YOUR CODE HERE +var x = 5; + +while (x >= 1) { + var y = x-1; + console.log ( + x + " bottles of beer on the wall, \n" + + x + " bottles of beer!\n" + + "Take one down and pass it around,\n" + + y + " bottles of beer on the wall...\n\n " + ) + x = x-1 + } + +BONUS + +var x = 5; + +while (x >= 1) { + var y = x-1; + + if (x==2) { + console.log ( + x + " bottles of beer on the wall, \n" + + x + " bottles of beer!\n" + + "Take one down and pass it around,\n" + + y + " bottle of beer on the wall...\n\n " + )} + + else if(x==1) { + console.log( + x + " bottle of beer on the wall, \n" + + x + " bottle of beer!\n" + + "Take one down and pass it around,\n" + + "No more bottles of beer on the wall...\n\n " + )} + + else { + console.log ( + x + " bottles of beer on the wall, \n" + + x + " bottles of beer!\n" + + "Take one down and pass it around,\n" + + y + " bottles of beer on the wall...\n\n " + )} + x = x-1; + }; From 08fe837cd4522e225a56b4204b40154b371f9e0b Mon Sep 17 00:00:00 2001 From: tgrahams101 Date: Thu, 30 Jun 2016 21:42:52 -0700 Subject: [PATCH 2/4] first workign solution for prime problem --- challenges/primes.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/challenges/primes.js b/challenges/primes.js index d95fd9e..8d44a74 100644 --- a/challenges/primes.js +++ b/challenges/primes.js @@ -10,3 +10,22 @@ */ // YOUR CODE HERE + + +function isPrime(number) { + var primeness=0; + for (i=2; i Date: Thu, 30 Jun 2016 21:56:06 -0700 Subject: [PATCH 3/4] seemingly working solution for 2nd section of prime problem --- challenges/primes.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/challenges/primes.js b/challenges/primes.js index 8d44a74..95bc3f0 100644 --- a/challenges/primes.js +++ b/challenges/primes.js @@ -29,3 +29,36 @@ function isPrime(number) { } } + +Problem 2 + + var array =[]; + +function isPrime(number) { + var primeness=0; + for (i=2; i Date: Fri, 1 Jul 2016 09:17:37 -0700 Subject: [PATCH 4/4] finished last two problems to deliver final submission --- challenges/palindrome-detector.js | 80 ++++++++++++++++++++ challenges/primes.js | 2 +- challenges/shakespearian-insult-generator.js | 55 +++++++++++++- 3 files changed, 135 insertions(+), 2 deletions(-) diff --git a/challenges/palindrome-detector.js b/challenges/palindrome-detector.js index 86e0a62..eab0305 100644 --- a/challenges/palindrome-detector.js +++ b/challenges/palindrome-detector.js @@ -21,3 +21,83 @@ */ // YOUR CODE HERE +/* I googled "how do I fetch last letter in a string, which brought me to this page +http://stackoverflow.com/questions/3884632/how-to-get-the-last-character-of-a-string +and from there it sparked some leads as to how I should proceed*/ + + +NEW AND UPDATED (THE WORD INPUTED MUST HAVE NO SPACES OR PUNCTUATION. FURTHERMORE, +THE SEQUENCE OF UPPERCASE/LOWERCASE MUST MATCH FROM BOTH DIRECTIONS) + +function isPalindrome(word){ + var theword= word; + var thelastletterindex=theword.length-1; + var divisibility=theword.length % 2; + var midpoint=0; + var palicheck=0; + if (divisibility===0){ + midpoint=theword.length/2; + } + else{ + var adjustlength=theword.length-1; + midpoint=adjustlength/2; + } + + for (n=0;n2){ + var divided=num/3; + var remainder=num % 3; + var count = Math.floor(divided); + for(i=0; i0){ + for (i=0;i