Skip to content

Dan McQuade - JavaScript Checkpoint #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions fundamentals.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,35 @@
// #1: Create an array of strings called `foods` that contains three foods.
// Type your solution immediately below this line:


var foods = ['tacos', 'burgers', 'shrimp']

// #2: Access the last item in the array and assign to a variable called `last`.
// Type your solution immediately below this line:


var last = foods[foods.length - 1]

// #3: Create an empty array called `favoriteFoods`.
// Type your solution immediately below this line:


var favoriteFoods = []

// #4: Create a `for` loop that adds each string in `foods` to `favoriteFoods`.
// Type your solution immediately below this line:


for (var i = 0; i < foods.length; i++) {
favoriteFoods.push(foods[i])
}

// #5: Create an object literal called `instructor` that contains three key-value pairs.
// Type your solution immediately below this line:


var instructor = {
name: 'Zakk',
cohort: 'WDI19',
strengths: 'Web Development'
}

// #6: Add a `has-office-hours` (spelled exactly) property to `instructor` by accessing
// it (do not change the original object you typed above) and assigning it
// a boolean value.
// Type your solution immediately below this line:
instructor['has-office-hours'] = true
8 changes: 7 additions & 1 deletion hof.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ var people = [
// called `peopleNames`.
// Type your solution immediately below this line:


var peopleNames = people.map((x) => {
return x.name
})

// #2: Use the `filter` array method to create a new, filtered array containing only
// persons from the `people` array who know multiple languages. Assign the returned array
// to a variable called `polyglotPeople`.
// Type your solution immediately below this line:

var polyglotPeople = people.filter((x) => {
return x.knownLanguages > 1
})
16 changes: 11 additions & 5 deletions oojs.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@
// - an `addSong` method that adds a song (string) to the `songs` array
// Type your solution immediately below this line:




class Playlist {
constructor (title) {
this.title = title
this.songs = []
}
addSong (newSong) {
this.songs.push(newSong)
}
}

// #2: Create an instance of the Playlist class and set it to a variable called `myPlaylist`
// Call the instance's `addSong` method to add a song to the instance's `songs` array
// Type your solution immediately below this line:

var myPlaylist = new Playlist('My Playlist')



myPlaylist.addSong('Who Let The Dogs Out')

// NOTE: THE CODE BELOW IS FOR TESTING PURPOSES. DO NOT REMOVE OR ALTER.
if(typeof Playlist !== 'undefined') {
Expand Down
101 changes: 87 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.