Hello. I tried the “Ask for help” button on this exercise and got a page that said " 414 Request-URI Too Large". Not sure what that means.
So I’ve successfully used the map method in solving prior code challenges but apparently I don’t have a good enough understanding of it to solve this challenge:
I looked at the hint and it provides an “Intermediate Code Solution.” Can someone explain what an “Intermediate Code Solution” is? Does that mean it’s not the complete solution, but only an intermediate step in solving the challenge? The “Intermediate Code Solution” provides the code below, but I don’t completely understand what the code is doing.
rating = watchList.map( (item) => ({"title":item["Title"], "rating":item["imdbRating"]}) );
I will explain as much as I understand and what I think I don’t understand then maybe someone can help clarify/explain.
First, the challenge provides this code:
var rating = [];
I’m not sure if this code is necessary, but I think it declares a variable called “rating” and assigns it to an empty array.
Then the solution code provided above then assigns the variable “rating” to the value of the map method that is used (invoked? called?) on the watchList array. I’m still not clear on what a callback function is but I think it’s the function that’s after the arrow =>
notation. (If anyone can clarify this and explain what we are calling back that would be helpful - I think? Also I’m still trying to figure out the difference between “invoke” and “call” and “callback”).
The map function iterates over every item in the watchList array and does something to each item. Specifically it calls a function that takes one input (parameter “item”) and then does something to each “item” (which I think means each object) in the watchList array.
I understand how the loop function works and that we are trying to do the same thing using the map method.
Did I get that right so far?
I don’t understand the following code:
({"title":item["Title"], "rating":item["imdbRating"]}) );
I’ve reviewed and re-reviewed the MDN explanation of the map method, searched the forums and read the postings about this challenge, googled this particular challenge and also the JS map method, and also searched topics that I thought might be relevant, like how to change an object in an array with the map method. But I still don’t understand the solution so I’m hoping someone can help.
thanks!