Permalink
Browse files

Merge pull request #4 from luisynayan/master

submitting Homework 1
  • Loading branch information...
vodnik committed Nov 30, 2018
2 parents 786f839 + 9a07dea commit ffa16e9d0bcae2bd332bb7612d7ec3b6eb6d8687
@@ -0,0 +1,27 @@
/*
Write code that prints the lyrics to "99 Bottles of Beer on the Wall" to the
console.
If you're unfamiliar with the song, you can find the lyrics here:
http://www.99-bottles-of-beer.net/lyrics.html.
Be sure that all of your output includes proper spacing (no words or values
running into each other).
Hint: You can make your output appear on multiple lines by using the string \n
to insert a line break.
BONUS: For an extra challenge, improve this code to print "1 bottle" rather
than "1 bottles" as well as the special lyrics for no bottles remaining (Hint:
read up on if/else conditional statements at https://mdn.io/if...else).
*/
for (let bottleCount = 99; bottleCount >= 0; bottleCount--){
if (bottleCount>1){
console.log(bottleCount + ' bottles of beer on the wall, ' + bottleCount + ' bottles of beer.\nTake one down, pass it around, ' + (bottleCount - 1) + ' bottles of beer on the wall. \n \n');
}
else if (bottleCount === 1){
console.log(bottleCount + ' bottle of beer on the wall, ' + bottleCount + ' bottle of beer.\nTake one down, pass it around, no more bottles of beer on the wall. \n \n');
} else {
console.log('No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall. \n \n');
}
}

@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<!-- js -->
<script src="app.js"></script>
</body>
</html>
@@ -0,0 +1,35 @@
/*
Write code that generates random addresses
Each time you load or reload the page in a browser, your program should log
a new randomly-generated address to the console.
Step 1:
Create arrays that contain dummy data for each of the following:
street number, street name, city name, state name, and zip code
Step 2:
Write code that randomly selects one item from each of these arrays, uses
the selected values to construct a string containing a random address, and
then logs the result to the console.
Step 3:
Save your work, load your app in the browser, open the console, and verify
that a random address is logged.
Step 4:
Reload the page and verify that a different random address is logged.
Example output:
34578 Dolphin Street, Wonka NY, 44506
*/
let streetNumber = ['123', '456', '789', '987', '654', '321', '111', '222', '333', '444'];
let streetName = ['Main St', 'A St', 'B St', 'C St', 'Embarcadero St', 'Pine St', 'Mission Blvd', 'Alvardo Blvd', '5th Ave'];
let cityName = ['San Francisco', 'Denver', 'Oakland', 'Detroit', 'Albany', 'Dallas', 'Las Vegas', 'Charlotte', 'Louisville', 'Los Angeles'];
let stateCode = ['CA', 'AZ', 'NY', 'KY', 'VA', 'MI', 'MA', 'NJ'];
let zipCode = ['94541', '10010', '65412', '82439', '86478', '31647'];

console.log(streetNumber[Math.floor(Math.random() * (streetNumber.length - 1))] + ' ' +
streetName[Math.floor(Math.random() * (streetName.length - 1))] + ', ' +
cityName[Math.floor(Math.random() * (cityName.length - 1))] + ', ' +
stateCode[Math.floor(Math.random() * (stateCode.length - 1))] + ' ' +
zipCode[Math.floor(Math.random() * (zipCode.length - 1))]);
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<!-- js -->
<script src="app.js"></script>
</body>
</html>
Oops, something went wrong.

0 comments on commit ffa16e9

Please sign in to comment.