I have been stuck at it for several days, i learned a lot by rereading some of the courses and searching on the internet, but some parts I sadly still don’t get.(Which in my defense aren’t always thaught during the courses, also there’s no tutorial video for this one).
I haven’t actually started the exercise, i want to understand the existing code first, that’s the key to solving this project I think. I will post and number my questions on the existing code under this text so it stays coherent.
Question 1: all of the functions look like getUser(url, request) etc etc but what are “url” and “request”?
Question 1.1: What’s Url? I thought something like thescoop.com/users/1 or is is it just users/1 without the first part?
Question 1.2: What’s the request? Is it something as in the lessons like this:
Accept: text/html, application/xhtml ?
Questions 1.3: If this is correct and someone has time to type this out, what would the request look like with a body?
Questions part 2, getUser function:
In this function we see a variable like this:
const username = url.split(’/’).filter(segment => segment);
Individually I understand what each part does, but I’m lost at the bigger picture.
Question 2.1: Can someone tell me what the result of this would be with a random url?
Question 2.2: Most of all I don’t understand what filter(segment => segment) does.
It’s a filter yes and an arrow function, but what does it do?
Part 3: in getArticles we see some code like this:
.map(articleId => database.articles[articleId]) .filter(article => article) .sort((article1, article2) => article2.id - article1.id)
Question 3: Can someone tell me what this returns or what each part of the code after object.keys does?
Part 4 is a similar issue: in several functions we see code like this:
const id = Number(url.split(’/’).filter(segment => segment));
I understand each part’s individual action but i can’t see what the total will produce.
So finally question 4 would be: what does this do and can someone illustrate with random url?
So, this was it, any help would be greatly appreciated.