Build a Library Manager - Step 11

hi. totally blind and cannot see. using the jaws for windows screen reader. on step 11 of this challenge build a library manager. have researched on google. but keep getting the error about the length of the array. what is the vallidator looking for. tried about 9 or more times. getting frustrated. reviewed my code. so what am i doing wrong. will paste my code and the error message below. can any one help me out. frustrated. marvin.

ps: pasting the code below.

let library = [ ];

library.push({
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
});

library.push({
title: “Atomic Habits”,
author: “James Clear”,
about: “A practical book about discarding bad habits and building good ones”,
pages: 320
});

function getBookInformation(catalog) {
return catalog.map(function(book) {
return book.title + " by " + book.author;
}).join(“\\n”);
}

function getBookSummaries(catalog) {
return catalog.map(function(book) {
return book.about;
});
}

Your getBookSummaries function should return an array with the same length as the array passed to it.

Please post a link to the step and format your code. If you follow these instructions it will do that for you automatically:

Click the Help button located on the challenge. This button only appears if you have tried to submit an answer at least three times.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

How long is the array that your function returns?

hi, the length of the array is 4. so how to fix? marvin.

That seems strange right? How did you come up with that number?

hi, was counting the number of items in the array. if not, then tell me how to do this . and not passing, and tried about 15 times. did try googling. and then rewrite my whole code. still not passing. so will have to search and see if i can find a code example so where i am going wrong. and no i did reset the lesson a few times. cannot see, totally blind and my screen reader jaws, has the correct spacing and indentation on vs studio code. so if you cannot help. then have to try my self. trying to do this, but first time doing higher functions and call back functions and using a screen reader.

marvin. s

How is counting the number of items in an object going to tell you the length of the array that your function returns?

This is an object, you can tell by the curly braces. An object has key/value pairs. It’s not an array.

let library = [ ];

library is your array, and you’ve pushed 2 objects onto it. The length of that array is 2.

Please share a link to the lab and instructions.

hi. okay did a local test in powershell. returns 4 items. so pasting the message and the code below. sent that to free code camp support. a bug in the vallidator. pasting the message, my code, the link to the step and the error.

Hi. Totally blind and using a screen reader. Doing the build a library manager app. And the validator keeps failing. So did a local test in powershell. It then returns the correct list of array elements 4.

So, can you help.

Will paste my code below.

Marvin.

Ps: pasting below.

const library = [

{ title: “Your Next Five Moves”, author: “Patrick Bet-David” },

{ title: “Atomic Habits”, author: “James Clear” },

{ title: “The 7 Habits of Highly Effective People”, author: “Stephen Covey” },

{ title: “Deep Work”, author: “Cal Newport” }

];

function getBookSummaries(catalog) {

return catalog.map(book => `${book.title} by ${book.author}`);

}

console.log(getBookSummaries(library));

https://www.freecodecamp.org/learn/full-stack-developer/workshop-library-manager/step-11

Your getBookSummaries function should return an array with the same length as the array passed to it.

.

I don’t recommend you doing anything locally. Previously this has resulted in you getting code from different lessons mixed up.

No that’s not the case…

Yes I know.

The code you’ve just shared is completely different than the code you first shared.

It’s also completely different than the code that starts step 11.

Reset the step.

Code only in the editor and follow the instructions.

Ask if you have a question about anything you don’t understand.

hi, found my original code. what stupid thing am i doing. have rewritten the function about 8 or 9 times. i dont understand. be gentle with me. a blind person so cannot see. whats if any other spacing or other errors. frustrated. any advice to get this to pass. pasting my code below. and the error. help? and it did show me the info in powershell on my local machine. so why? frustrated. did try googling, but could not find a code solution from any one that may have posted on the forum. so any advice. frustrated. and using a screen reader. have reset the lesson about 15 times, and still not passing. driving me nuts. tried to fix this for the past 3 hours. help. pasting below:

ps: pasting the code and the error.


const library = [

{ title: “Your Next Five Moves: Master the Art of Business Strategy”, author: “Patrick Bet-David”, alreadyRead: true },

{ title: “Atomic Habits”, author: “James Clear”, alreadyRead: false },

{ title: “Deep Work”, author: “Cal Newport”, alreadyRead: true }

];

function getBookSummaries(libraryArray) {

// Ensure output array has same length as input

let summaries = new Array(libraryArray.length);

for (let i = 0; i < libraryArray.length; i++) {

let book = libraryArray[i];

summaries[i] = book.title + " by " + book.author;

}

return summaries;

}

// Test

console.log(getBookSummaries(library));

// Output: array of same length as library

Your getBookSummaries function should return an array with the same length as the array passed to it.

why do you have written that code inside bookSummaries?

hi, i dont know. you tell me as you are the expert. first time newbie learning about higher functions. so tell me why and then how to get it to pass.

marvin.

You wrote that code, I can’t know why you wrote it

If you explain your reasoning we may be able to help with any confusion

hi, maybe i was trying things around. not sure. so help me out. if not, then point me to where i can find a code xample to compare with my code. just frustrated. blind and first time doing higher functions. can you help. so, point me in the right direction.

marvin.

We can’t help you if you keep doing this and you don’t listen to our advice. Your code is missing basic things it started with that you need to complete this step.

Don’t “google” a solution it’s causing you to write nonsense. What is this:

alreadyRead: false
  1. Reset the step.
  2. Read the instructions.
  3. If there is something you don’t understand, ask about it.

Otherwise, no one can help you.

You are not even asking knowledgeable questions so I don’t think that you really understand anything about this workshop. That’s not helping you to learn.

Please stop wasting your time and everyone else’s.

I can’t help you like this, if you explain your doubts about how your code works I am happy to answer them

I’m working on Step 11 of the Higher Functions workshop. I’m trying to create a getBookSummaries function that returns an array of summaries from a library array of book objects. My function returns the correct strings, and I’ve checked that the array length matches the input array, but the FreeCodeCamp validator keeps giving me:

const library = [
{ title: “Your Next Five Moves”, author: “Patrick Bet-David”, alreadyRead: true, about: “Business strategy book” },
{ title: “Atomic Habits”, author: “James Clear”, alreadyRead: false, about: “Book about habits” },
{ title: “Deep Work”, author: “Cal Newport”, alreadyRead: true, about: “Focus and productivity” }
];

function getBookSummaries(books) {
return books.map(book => book.about);
}I’ve tried using .map() and a for loop, and verified that the output array has the same number of elements as the input. I’m not sure why the validator still fails.

Could someone please advise if I’m missing something specific about the validator’s expectations? I’m not asking for a solution, just guidance to understand why my code isn’t passing.

Thanks so much!

it doesn’t return the correct string, this library you have is not the one that is provided at the start of the step