diff --git a/client/i18n/locales/english/intro.json b/client/i18n/locales/english/intro.json index b9ee5a82ef2..2240dd7150d 100644 --- a/client/i18n/locales/english/intro.json +++ b/client/i18n/locales/english/intro.json @@ -2776,7 +2776,12 @@ "In these lecture videos, you will learn about working with higher order functions and callbacks." ] }, - "vjmm": { "title": "183", "intro": [] }, + "workshop-library-manager": { + "title": "Build a Library Manager", + "intro": [ + "In this workshop, you will learn higher order array methods by building a library manager" + ] + }, "bxtv": { "title": "184", "intro": [] }, "review-javascript-higher-order-functions": { "title": "JavaScript Higher Order Functions Review", diff --git a/client/src/pages/learn/full-stack-developer/workshop-library-manager/index.md b/client/src/pages/learn/full-stack-developer/workshop-library-manager/index.md new file mode 100644 index 00000000000..acc34ac6d99 --- /dev/null +++ b/client/src/pages/learn/full-stack-developer/workshop-library-manager/index.md @@ -0,0 +1,9 @@ +--- +title: Introduction to the Build a Library Manager +block: workshop-library-manager +superBlock: full-stack-developer +--- + +## Introduction to the Build a Library Manager + +This is a test for the new project-based curriculum. diff --git a/curriculum/challenges/_meta/workshop-library-manager/meta.json b/curriculum/challenges/_meta/workshop-library-manager/meta.json new file mode 100644 index 00000000000..62842749b27 --- /dev/null +++ b/curriculum/challenges/_meta/workshop-library-manager/meta.json @@ -0,0 +1,45 @@ +{ + "name": "Build a Library Manager", + "blockLayout": "challenge-grid", + "isUpcomingChange": true, + "usesMultifileEditor": true, + "hasEditableBoundaries": true, + "dashedName": "workshop-library-manager", + "superBlock": "full-stack-developer", + "challengeOrder": [ + { + "id": "67116c175a77cb64c5c10d49", + "title": "Step 1" + }, + { + "id": "67116d7584d0b469b14579bf", + "title": "Step 2" + }, + { + "id": "67116d7584d0b469b14579c0", + "title": "Step 3" + }, + { + "id": "67116d7584d0b469b14579c1", + "title": "Step 4" + }, + { + "id": "67116d7584d0b469b14579c2", + "title": "Step 5" + }, + { + "id": "67116d7584d0b469b14579c3", + "title": "Step 6" + }, + { + "id": "67116d7584d0b469b14579c4", + "title": "Step 7" + }, + { + "id": "67190ce4fe18911edc2018d2", + "title": "Step 8" + } + ], + "helpCategory": "JavaScript", + "blockType": "workshop" +} \ No newline at end of file diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116c175a77cb64c5c10d49.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116c175a77cb64c5c10d49.md new file mode 100644 index 00000000000..4168001c5b5 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116c175a77cb64c5c10d49.md @@ -0,0 +1,38 @@ +--- +id: 67116c175a77cb64c5c10d49 +title: Step 1 +challengeType: 1 +dashedName: step-1 +--- + +# --description-- + +In the previous lecture videos, you learned how to work with higher order functions like `map`, `filter` and `reduce`. + +In this workshop, you will build a library manager app that will give you an opportunity to practice working with different higher order functions. + +To get started, create a variable called `library` and assign it an empty array. + +# --hints-- + +You should create a `library` array. + +```js +assert.isArray(library) +``` + +Your `library` array should be empty. + +```js +assert.isEmpty(library) +``` + +# --seed-- + +## --seed-contents-- + +```js +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579bf.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579bf.md new file mode 100644 index 00000000000..8a26dfd0c6b --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579bf.md @@ -0,0 +1,91 @@ +--- +id: 67116d7584d0b469b14579bf +title: Step 2 +challengeType: 1 +dashedName: step-2 +--- + +# --description-- + +Inside the `library` array, create an object with the following properties and values: + +| Property | Value | +| ----------- | ------- | +| `title` | `"Your Next Five Moves: Master the Art of Business Strategy"`| +| `author` | `"Patrick Bet-David and Greg Dinkin"`| +| `about` | `"A book on how to plan ahead"`| +| `pages` | `320` | + +# --hints-- + +You should have an object inside the `library` array. + +```js +assert.isObject(library[0]) +``` + +Your object should have a `title` property. + +```js +assert.property(library[0], "title") +``` + +The value of your `title` property should be `"Your Next Five Moves: Master the Art of Business Strategy"`. + +```js +assert.propertyVal(library[0], "title", "Your Next Five Moves: Master the Art of Business Strategy"); +``` + +Your object should have an `author` property. + +```js +assert.property(library[0], "author") +``` + +Your `author` property should have the value `"Patrick Bet-David and Greg Dinkin"`. + +```js +assert.propertyVal(library[0], "author", "Patrick Bet-David and Greg Dinkin"); +``` + +Your object should have an `about` property. + +```js +assert.property(library[0], "about") +``` + +Your `about` property should have the value `"A book on how to plan ahead"`. + +```js +assert.propertyVal(library[0], "about", "A book on how to plan ahead"); +``` + +Your object should have a `pages` property. + +```js +assert.property(library[0], "pages") +``` + +The value of yoour `pages` property should be a number. + +```js +assert.isNumber(library[0]?.pages) +``` + +Your `pages` property should be set to `320`. + +```js +assert.propertyVal(library[0], "pages", 320); +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ +--fcc-editable-region-- + +--fcc-editable-region-- +]; +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c0.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c0.md new file mode 100644 index 00000000000..fbbdccf2475 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c0.md @@ -0,0 +1,98 @@ +--- +id: 67116d7584d0b469b14579c0 +title: Step 3 +challengeType: 1 +dashedName: step-3 +--- + +# --description-- + +Create another object inside the `library` array with the following properties and values: + +| Property | Value | +| ----------- | ------- | +| `title` | `"Atomic Habits"`| +| `author` | `"James Clear"`| +| `about` | `"A practical book about discarding bad habits and building good ones"`| +| `pages` | `320` | + +# --hints-- + + +You should have an object as the second item of your `library` array. + +```js +assert.isObject(library[1]); +``` + +Your object should have a `title` property. + +```js +assert.property(library[1], "title") +``` + +Your `title` property should have `"Atomic Habits"` as its value. + +```js +assert.propertyVal(library[1], "title", "Atomic Habits"); +``` + +Your object should have an `author` property. + +```js +assert.property(library[1], "author") +``` + +Your `author` property should have `"James Clear"` as its value. + +```js +assert.propertyVal(library[1], "author", "James Clear"); +``` + +Your object should have an `about` property. + +```js +assert.property(library[1], "about") +``` + +Your `about` property should have the value `"A practical book about discarding bad habits and building good ones"`. + +```js +assert.propertyVal(library[1], "about", "A practical book about discarding bad habits and building good ones"); +``` + +Your object should have a `pages` property. + +```js +assert.property(library[1], "pages") +``` + +The value of your `pages` property should be a number. + +```js +assert.isNumber(library[1]?.pages) +``` + +Your `pages` property should be set to `320`. + +```js +assert.propertyVal(library[1], "pages", 320); +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, +--fcc-editable-region-- + +--fcc-editable-region-- +]; +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c1.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c1.md new file mode 100644 index 00000000000..6bb742208df --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c1.md @@ -0,0 +1,122 @@ +--- +id: 67116d7584d0b469b14579c1 +title: Step 4 +challengeType: 1 +dashedName: step-4 +--- + +# --description-- + +The rest of the objects representing the books have been filled in for you. You can take a look at them. + +Now, you should start working on getting several common parts of the books. + +Start by displaying all the books. Create a `displayBooks` function with a `catalog` parameter. The function should return a string that contains the `title`, `author`, and `pages` of all the books in the `library` array. + +# --hints-- + +You should create a `displayBooks` function. + +```js +assert.isFunction(displayBooks) +``` + +Your `displayBooks` function should have a `catalog` parameter. + +```js +assert.match(displayBooks.toString(), /catalog/) +``` + +Your `displayBooks` function should use a higher order function. Ex. (`filter`, `map`, `reduce`) + +```js +assert.match(displayBooks.toString(), /filter|map|reduce|forEach/); +``` + +Your `displayBooks` function should return a string. + +```js +assert.isString(displayBooks(library)) +``` + +Your `displayBooks` function should have each book title, author and pages in it. + +```js +library.forEach((book) => { + assert.include(displayBooks(library), book.title); + assert.include(displayBooks(library), book.author); + assert.include(displayBooks(library), book.pages.toString()); +}); +``` + +Your `displayBooks` function should contain the total of `8` books avaialble in the library. + +```js +function getNumOfBooks(catalog) { + return catalog.map(book => `${book.title} by ${book.author}`); +} + +assert.lengthOf(getNumOfBooks(library), 8); +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, + { + title: 'Atomic Habits', + author: 'James Clear', + about: 'A practical book about discarding bad habits and building good ones', + pages: 320, + }, + { + title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few', + author: 'Patrick Bet-David', + about: + "A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world", + pages: 304, + }, + { + title: 'The Embedded Entrepreneur', + author: 'Arvid Kahl', + about: 'A book focusing on how to build an audience-driven business', + pages: 308, + }, + { + title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change', + author: 'Jon Gordon', + about: 'A book about effective ways to lead a coffee bean lifestyle', + pages: 256, + }, + { + title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation', + author: 'Jeff DeGraff and Staney DeGraff', + about: 'A book on how to develop creativity and innovation skills', + pages: 168, + }, + { + title: 'Rich Dad Poor Dad', + author: 'Robert Kiyosaki and Sharon Lechter', + about: 'A book about financial literacy, financial independence, and building wealth. ', + pages: 336, + }, + { + title: 'Zero to Sold', + author: 'Arvid Kahl', + about: 'A book on how to bootstrap a business', + pages: 500, + }, +]; + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c2.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c2.md new file mode 100644 index 00000000000..533d9a351dd --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c2.md @@ -0,0 +1,124 @@ +--- +id: 67116d7584d0b469b14579c2 +title: Step 5 +challengeType: 1 +dashedName: step-5 +--- + +# --description-- + +To display the book summaries, you can use the `about` property of each book. + +Create a `getBookSummaries` function with a `catalog` parameter. The `getBookSummaries` function should return an array containing all the `about` property value of each book. + +# --hints-- + +You should create a `getBookSummaries` function. + +```js +assert.isFunction(getBookSummaries) +``` + +Your `getBookSummaries` function should have a `catalog` parameter. + +```js +assert.match(getBookSummaries.toString(), /catalog/) +``` + +Your `getBookSummaries` function should return an array. + +```js +assert.isArray(getBookSummaries(library)) +``` + +Your `getBookSummaries` function should use a higher order function. Ex. (`filter`, `map`, `reduce`). + +```js +assert.match(getBookSummaries.toString(), /filter|map|reduce|forEach/); +``` + +Your `getBookSummaries` function should contain the total of `8` books avaialble in the library. + +```js +assert.lengthOf(getBookSummaries(library), 8); +``` + +Your `getBookSummaries` function should have the `about` property of each book in the library. + +```js +library.forEach((book) => { + assert.include(getBookSummaries(library), book.about); +}); +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, + { + title: 'Atomic Habits', + author: 'James Clear', + about: 'A practical book about discarding bad habits and building good ones', + pages: 320, + }, + { + title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few', + author: 'Patrick Bet-David', + about: + "A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world", + pages: 304, + }, + { + title: 'The Embedded Entrepreneur', + author: 'Arvid Kahl', + about: 'A book focusing on how to build an audience-driven business', + pages: 308, + }, + { + title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change', + author: 'Jon Gordon', + about: 'A book about effective ways to lead a coffee bean lifestyle', + pages: 256, + }, + { + title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation', + author: 'Jeff DeGraff and Staney DeGraff', + about: 'A book on how to develop creativity and innovation skills', + pages: 168, + }, + { + title: 'Rich Dad Poor Dad', + author: 'Robert Kiyosaki and Sharon Lechter', + about: 'A book about financial literacy, financial independence, and building wealth. ', + pages: 336, + }, + { + title: 'Zero to Sold', + author: 'Arvid Kahl', + about: 'A book on how to bootstrap a business', + pages: 500, + }, +]; + +function displayBooks(catalog) { + let output = 'Books in the Library:\n'; + + catalog.forEach((book) => { + output += `- ${book.title} by ${book.author} (${book.pages} pages)\n`; + }); + + return output; +} + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c3.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c3.md new file mode 100644 index 00000000000..61af619580b --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c3.md @@ -0,0 +1,136 @@ +--- +id: 67116d7584d0b469b14579c3 +title: Step 6 +challengeType: 1 +dashedName: step-6 +--- + +# --description-- + +Another useful thing to do is to get the books by their author. + +Create a `getBooksByAuthor` function with a `catalog` and `author` parameters. + +The function must return an array that contains the books by a particular author. + +# --hints-- + +You should create a `getBooksByAuthor` function. + +```js +assert.isFunction(getBooksByAuthor) +``` + +Your `getBooksByAuthor` function should have a `catalog` and `author` parameters. + +```js +assert.match(getBooksByAuthor.toString(), /catalog,\s*author|author,\s*catalog/) +``` + +Your `getBooksByAuthor` function should return an array. + +```js +assert.isArray(getBooksByAuthor(library)) +``` + +Your `getBooksByAuthor` function should use a higher order function. Ex. (`filter`, `map`, `reduce`). + +```js +assert.match(getBooksByAuthor.toString(), /filter|map|reduce|forEach/); +``` + +Your `getBooksByAuthor` function should return the correct number of books for any of the authors. + +```js +const arvidKahlBooks = getBooksByAuthor(library, 'Arvid Kahl'); +const robertAndSharonBook = getBooksByAuthor(library, 'Robert Kiyosaki and Sharon Lechter'); +const pbdAndGDBooks = getBooksByAuthor(library, 'Patrick Bet-David and Greg Dinkin'); +const pbdBook = getBooksByAuthor(library, 'Patrick Bet-David'); +const johnGordon = getBooksByAuthor(library, 'Jon Gordon'); +const jamesClearBook = getBooksByAuthor(library, 'James Clear'); +const JDAndSDBook = getBooksByAuthor(library, 'Jeff DeGraff and Staney DeGraff'); + +assert.lengthOf(arvidKahlBooks, 2); +assert.lengthOf(robertAndSharonBook, 1); +assert.lengthOf(pbdAndGDBooks, 1); +assert.lengthOf(pbdBook, 1); +assert.lengthOf(johnGordon, 1); +assert.lengthOf(jamesClearBook, 1); +assert.lengthOf(JDAndSDBook, 1); +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, + { + title: 'Atomic Habits', + author: 'James Clear', + about: 'A practical book about discarding bad habits and building good ones', + pages: 320, + }, + { + title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few', + author: 'Patrick Bet-David', + about: + "A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world", + pages: 304, + }, + { + title: 'The Embedded Entrepreneur', + author: 'Arvid Kahl', + about: 'A book focusing on how to build an audience-driven business', + pages: 308, + }, + { + title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change', + author: 'Jon Gordon', + about: 'A book about effective ways to lead a coffee bean lifestyle', + pages: 256, + }, + { + title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation', + author: 'Jeff DeGraff and Staney DeGraff', + about: 'A book on how to develop creativity and innovation skills', + pages: 168, + }, + { + title: 'Rich Dad Poor Dad', + author: 'Robert Kiyosaki and Sharon Lechter', + about: 'A book about financial literacy, financial independence, and building wealth. ', + pages: 336, + }, + { + title: 'Zero to Sold', + author: 'Arvid Kahl', + about: 'A book on how to bootstrap a business', + pages: 500, + }, +]; + +function displayBooks(catalog) { + let output = 'Books in the Library:\n'; + + catalog.forEach((book) => { + output += `- ${book.title} by ${book.author} (${book.pages} pages)\n`; + }); + + return output; +} + +function getBookSummaries(catalog) { + return catalog.map((book) => book.about); +} + +--fcc-editable-region-- + +--fcc-editable-region-- +``` diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c4.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c4.md new file mode 100644 index 00000000000..aa4182128b9 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67116d7584d0b469b14579c4.md @@ -0,0 +1,124 @@ +--- +id: 67116d7584d0b469b14579c4 +title: Step 7 +challengeType: 1 +dashedName: step-7 +--- + +# --description-- + +Finally, create a `getTotalPages` function with a `catalog` parameter. The function should return the total number of all the pages of the books in the `library` array. + +# --hints-- + + +You should create a `getTotalPages` function. + +```js +assert.isFunction(getTotalPages) +``` + +Your `getTotalPages` function should have a `catalog` parameter. + +```js +assert.match(getTotalPages.toString(), /catalog/) +``` + +Your `getTotalPages` function should return a number. + +```js +assert.isNumber(getTotalPages(library)) +``` + +Your `getTotalPages` function should return the number `2512`. + +```js +assert.equal(getTotalPages(library), 2512); +``` + +Your `getTotalPages` function should use a higher order function. Ex. (`filter`, `map`, `reduce`). + +```js +assert.match(getTotalPages.toString(), /filter|map|reduce|forEach/); +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, + { + title: 'Atomic Habits', + author: 'James Clear', + about: 'A practical book about discarding bad habits and building good ones', + pages: 320, + }, + { + title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few', + author: 'Patrick Bet-David', + about: + "A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world", + pages: 304, + }, + { + title: 'The Embedded Entrepreneur', + author: 'Arvid Kahl', + about: 'A book focusing on how to build an audience-driven business', + pages: 308, + }, + { + title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change', + author: 'Jon Gordon', + about: 'A book about effective ways to lead a coffee bean lifestyle', + pages: 256, + }, + { + title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation', + author: 'Jeff DeGraff and Staney DeGraff', + about: 'A book on how to develop creativity and innovation skills', + pages: 168, + }, + { + title: 'Rich Dad Poor Dad', + author: 'Robert Kiyosaki and Sharon Lechter', + about: 'A book about financial literacy, financial independence, and building wealth. ', + pages: 336, + }, + { + title: 'Zero to Sold', + author: 'Arvid Kahl', + about: 'A book on how to bootstrap a business', + pages: 500, + }, +]; + +function displayBooks(catalog) { + let output = 'Books in the Library:\n'; + + catalog.forEach((book) => { + output += `- ${book.title} by ${book.author} (${book.pages} pages)\n`; + }); + + return output; +} + +function getBookSummaries(catalog) { + return catalog.map((book) => book.about); +} + +function getBooksByAuthor(catalog, author) { + return catalog.filter((book) => book.author === author); +} + +--fcc-editable-region-- + +--fcc-editable-region-- +``` + diff --git a/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67190ce4fe18911edc2018d2.md b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67190ce4fe18911edc2018d2.md new file mode 100644 index 00000000000..785982bc8b4 --- /dev/null +++ b/curriculum/challenges/english/25-front-end-development/workshop-library-manager/67190ce4fe18911edc2018d2.md @@ -0,0 +1,264 @@ +--- +id: 67190ce4fe18911edc2018d2 +title: Step 8 +challengeType: 1 +dashedName: step-8 +--- + +# --description-- + +Now, you should test out the functions by calling them with the appropriate arguments. + +Create four new variables: `libraryBooks`, `bookSummaries`, `booksByArvidKahl`, and `totalPagesOfBooksInLibrary`. Set them all to the calling of `displayBooks()`, `getBookSummaries()`, `getBooksByAuthor()`, and `getTotalPages()` respectively with the appropriate parameters. + +Log all the variables to the console. + +With that, your library manager workshop is complete. + +# --hints-- + +You should create a `libraryBooks` variable. + +```js +assert.isNotNull(libraryBooks) +``` + +Your `libraryBooks` variable should be set to `displayBooks(library)`. + +```js +assert.equal(libraryBooks, displayBooks(library)); +``` + +You should log the `libraryBooks` variable to the console. + +```js +assert.match(code, /console\.log\(libraryBooks\);?/) +``` + +You should create a `bookSummaries` variable. + +```js +assert.isNotNull(bookSummaries) +``` + +Your `bookSummaries` variable should be set to `getBookSummaries(library)`. + +```js +assert.deepEqual(bookSummaries, getBookSummaries(library)); +``` + +You should log the `bookSummaries` variable to the console. + +```js +assert.match(code, /console\.log\(bookSummaries\);?/) +``` + +You should create a `booksByArvidKahl` variable. + +```js +assert.isNotNull(booksByArvidKahl) +``` + +Your `booksByArvidKahl` variable should be set to `getBooksByAuthor(library, 'Arvid Kahl')`. + +```js +assert.deepEqual(booksByArvidKahl, getBooksByAuthor(library, 'Arvid Kahl')); +``` + +You should log the `booksByArvidKahl` variable to the console. + +```js +assert.match(code, /console\.log\(booksByArvidKahl\);?/) +``` + +You should create a `totalPagesOfBooksInLibrary` variable. + +```js +assert.isNotNull(totalPagesOfBooksInLibrary) +``` + +Your `totalPagesOfBooksInLibrary` variable should be set to `getTotalPages(library)`. + +```js +assert.deepEqual(totalPagesOfBooksInLibrary, getTotalPages(library)); +``` + +You should log the `totalPagesOfBooksInLibrary` variable to the console. + +```js +assert.match(code, /console\.log\(totalPagesOfBooksInLibrary\);?/) +``` + +# --seed-- + +## --seed-contents-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, + { + title: 'Atomic Habits', + author: 'James Clear', + about: 'A practical book about discarding bad habits and building good ones', + pages: 320, + }, + { + title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few', + author: 'Patrick Bet-David', + about: + "A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world", + pages: 304, + }, + { + title: 'The Embedded Entrepreneur', + author: 'Arvid Kahl', + about: 'A book focusing on how to build an audience-driven business', + pages: 308, + }, + { + title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change', + author: 'Jon Gordon', + about: 'A book about effective ways to lead a coffee bean lifestyle', + pages: 256, + }, + { + title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation', + author: 'Jeff DeGraff and Staney DeGraff', + about: 'A book on how to develop creativity and innovation skills', + pages: 168, + }, + { + title: 'Rich Dad Poor Dad', + author: 'Robert Kiyosaki and Sharon Lechter', + about: 'A book about financial literacy, financial independence, and building wealth. ', + pages: 336, + }, + { + title: 'Zero to Sold', + author: 'Arvid Kahl', + about: 'A book on how to bootstrap a business', + pages: 500, + }, +]; + +function displayBooks(catalog) { + let output = 'Books in the Library:\n'; + + catalog.forEach((book) => { + output += `- ${book.title} by ${book.author} (${book.pages} pages)\n`; + }); + + return output; +} + +function getBookSummaries(catalog) { + return catalog.map((book) => book.about); +} + +function getBooksByAuthor(catalog, author) { + return catalog.filter((book) => book.author === author); +} + +function getTotalPages(catalog) { + return catalog.reduce((acc, book) => acc + book.pages, 0); +} + +--fcc-editable-region-- + +--fcc-editable-region-- +``` + +# --solutions-- + +```js +const library = [ + { + title: 'Your Next Five Moves: Master the Art of Business Strategy', + author: 'Patrick Bet-David and Greg Dinkin', + about: 'A book on how to plan ahead', + pages: 320, + }, + { + title: 'Atomic Habits', + author: 'James Clear', + about: 'A practical book about discarding bad habits and building good ones', + pages: 320, + }, + { + title: 'Choose Your Enemies Wisely: Business Planning for the Audacious Few', + author: 'Patrick Bet-David', + about: + "A book that emphasizes the importance of identifying and understanding one's adversaries to succeed in the business world", + pages: 304, + }, + { + title: 'The Embedded Entrepreneur', + author: 'Arvid Kahl', + about: 'A book focusing on how to build an audience-driven business', + pages: 308, + }, + { + title: 'How to Be a Coffee Bean: 111 Life-Changing Ways to Create Positive Change', + author: 'Jon Gordon', + about: 'A book about effective ways to lead a coffee bean lifestyle', + pages: 256, + }, + { + title: 'The Creative Mindset: Mastering the Six Skills That Empower Innovation', + author: 'Jeff DeGraff and Staney DeGraff', + about: 'A book on how to develop creativity and innovation skills', + pages: 168, + }, + { + title: 'Rich Dad Poor Dad', + author: 'Robert Kiyosaki and Sharon Lechter', + about: 'A book about financial literacy, financial independence, and building wealth. ', + pages: 336, + }, + { + title: 'Zero to Sold', + author: 'Arvid Kahl', + about: 'A book on how to bootstrap a business', + pages: 500, + }, +]; + +function displayBooks(catalog) { + let output = 'Books in the Library:\n'; + + catalog.forEach((book) => { + output += `- ${book.title} by ${book.author} (${book.pages} pages)\n`; + }); + + return output; +} + +function getBookSummaries(catalog) { + return catalog.map((book) => book.about); +} + +function getBooksByAuthor(catalog, author) { + return catalog.filter((book) => book.author === author); +} + +function getTotalPages(catalog) { + return catalog.reduce((acc, book) => acc + book.pages, 0); +} + +const bookSummaries = getBookSummaries(library); +console.log(bookSummaries); + +const libraryBooks = displayBooks(library); +console.log(libraryBooks); + +const booksByArvidKahl = getBooksByAuthor(library, 'Arvid Kahl'); +console.log(booksByArvidKahl); + +const totalPagesOfBooksInLibrary = getTotalPages(library); +console.log(totalPagesOfBooksInLibrary); +``` diff --git a/curriculum/superblock-structure/full-stack.json b/curriculum/superblock-structure/full-stack.json index 0a8126428ab..94970de4196 100644 --- a/curriculum/superblock-structure/full-stack.json +++ b/curriculum/superblock-structure/full-stack.json @@ -372,6 +372,7 @@ { "dashedName": "lecture-working-with-higher-order-functions-and-callbacks" }, + { "dashedName": "workshop-library-manager" }, { "dashedName": "review-javascript-higher-order-functions" }, { "dashedName": "quiz-javascript-higher-order-functions" } ]