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; + }; 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