# submitting Homework 2 #6

Merged
merged 2 commits into from Dec 12, 2018
Commits
Filter file types
Failed to load files and symbols.
+1,282 −0

#### Just for now

@@ -0,0 +1,90 @@
// Relying on your newfound knowledge of loops, combine loops and if/else statements together and incrementally build the common fizzbuzz loop.

// - In the loop, every time a number is divisible by **3**, instead of logging the number itself, the word "fizz" should appear.
// - If the number is divisible by **5**, the word "buzz" should be logged.
// - If the number is divisible by both **3** and **5**, then the word "fizzbuzz" should be logged.

// ##### Step 1:
// Construct a for loop that iterates through, and `console.log()`'s out, numbers 1 - 100.

// for (let i = 1; i <= 100; i++){
// console.log(i);
// }

// ##### Step 2:
// Add an `if/else` statement that logs the string `"fizz"` if the value being iterated over is divisible by `3`; otherwise, log out the value.

// for (let i = 1; i <= 100; i++){

#### vodnik Dec 12, 2018

Owner

I like that you kept each iteration as a comment and expanded on it for each step.

// if (i%3 === 0){

#### vodnik Dec 12, 2018

Owner

I recommend getting in the habit of including a space around each operator, for readability.

// console.log('fizz');
// }
// else{
// console.log(i);
// }
// }

// ##### Step 3:
// Add an `else if` clause that logs the string `"buzz"` if the value being iterated over is divisible by `5`.

// for (let i = 1; i <= 100; i++){
// if (i%3 === 0){
// console.log('fizz');
// }
// else if (i%5 === 0){
// console.log('buzz');
// }
// else{
// console.log(i);
// }
// }

// ##### Step 4:
// Add an additional `else if` clause that logs the string `"fizzbuzz"` if the value being iterated over is divisible by both `3` and `5`.

// for (let i = 1; i <= 100; i++){
// if ((i%3 === 0) && (i%5 ===0)){
// console.log('fizzbuzz');
// }
// else if (i%3 === 0){
// console.log('fizz');
// }
// else if (i%5 === 0){
// console.log('buzz');
// }
// else{
// console.log(i);
// }
// }

//##### BONUS:

// a. Make a copy of your existing code and comment out the original.
// b. In the new copy, instead of using console.log for the results, push the
// result of each loop to an array.
// c. After all iterations have, completed, use the forEach array method to log
// each array element value to the console.
// Label your console output with the original number and a colon before each
// array value. (Hint: How can you shorten your code using a second forEach
// function parameter?)

let myArray = [];
for (let i = 1; i <= 100; i++){
if ((i%3 === 0) && (i%5 ===0)){
myArray.push('fizzbuzz');
}
else if (i%3 === 0){
myArray.push('fizz');
}
else if (i%5 === 0){
myArray.push('buzz');
}
else{
myArray.push(i);
}
}

myArray.forEach(function(element, myIndex){

#### vodnik Dec 12, 2018

Owner

Nice work implementing a two-parameter `forEach` statement!

console.log((myIndex + 1) + ":" + element);
})
 @@ -0,0 +1,9 @@
@@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////

///////////////////////// Challenge /////////////////////////

/////////////////////////////////////////////////////////////

// 1. Suppose that we wanted to create a browser-based calendar program for keeping track of things. In comments, list at least three reasonable abstractions that you might use to build this program; for each abstraction, list out at least two properties and behaviors that it would make sense for that abstraction to have. Below is an example - please write your answer in the same format.
// 'Car'
// Description: Our app manages car sales.
// Every 'car' has
// - a make
// - a model
// - a year
// Every 'car' can
// - drive
// - brake
// - park

// 'Reminder'
// Description: A reminder the user can create on the calendar app
// Every 'reminder' has
// - a date
// - a start time
// - an end time
// - a description
// Every 'reminder' can
// - remove a reminder
// - edit a reminder

// 'Month'
// Description: The months on our calendar app
// Every 'month' has
// - name
// - number of days
// - starting weekday
// Every 'month' can
// - show days with reminders
// - show days with no reminders

// 'Day'
// Description: The specific days on our calendar app
// 'Every day has
// - date
// - timeframes
// Every 'day' can
// - show all reminders per timeframe
// - edit reminders

// 2. Create an Object literal that lines up with the following description. Store it in the variable 'pet_owner', below. Be sure to give it reasonable values for each of its properties.

// 'Owner'
// Description: We are making an app for a veterinary clinic - it manages pets' vaccinations.
// Every 'owner' has:
// - a name

let pet_owner;

pet_owner = {
ownerName: 'Luis Ynayan',
ownerAddress: '123 Main St, San Francisco, CA 94016',
}

// 3. Create an Object literal that lines up with the following description. Store it in the variable `some_pet`, below.

// Pet
// Description: We are making an app for a veterinary clinic - it manages pets' vaccinations.
// Every 'pet' has:
// - a name
// - a species
// - a breed
// - a noise that it can make (e.g. 'bark', 'meow', etc.)
// Every pet can:
// - make noise (each pet makes its own unique noise, as specified by `noise`.

let some_pet;

some_pet = {
petName: 'Vinny',
species: 'Dog',
breed: 'Poodle',
noise: 'bark',
makeNoise: function(){
console.log(this.petName + ' says: ' + this.noise);

#### vodnik Dec 12, 2018

Owner

Nice job using `this` to make a flexible object.

}
}