Learn Modern JavaScript Methods by Building Football Team Cards - Step 23

Tell us what’s happening:

i think i have 2 problems:

  1. i’m not 100% sure what an empty callback function is supposed to look like in this case. Should it look like this? : ()=>{}.
  2. i need to assign that which is being mapped to playersCards.innerHTML but how do i do this when the parameter is empty?
    i’m so confused. thanks

Your code so far

<!-- file: index.html -->

/* file: styles.css */

/* file: script.js */
// User Editable Region

arr.map( ()=>{
    arr += playersCards.innerHTML;
}
)


// User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36

Challenge Information:

Learn Modern JavaScript Methods by Building Football Team Cards - Step 23

Hello FstCrsElctrcGtrs,

  1. i’m not 100% sure what an empty callback function is supposed to look like in this case. Should it look like this? : ()=>{}.

Yes that’s correct.

2.i need to assign that which is being mapped to playersCards.innerHTML but how do i do this when the parameter is empty?

It doesn’t really matter if it’s “empty” or not. But right now in your code, instead of assigning the new array to playerCards.innerHTML. You tried to assign playerCards.innerHTML to arr.

As you stated in your first question you indeed need to only add an empty callback function in the map method.
Then once you’ve done that. You will to use the += (addition assignment) operator to assign this to playerCards.innerHTML.

what is the ‘this’ you are referring to? that is what i am stuck on. that’s why i assigned it to arr, because i have no idea what exactly i am supposed to be assigning playerCards.innerHTML to!

assign the new array to playerCards.innerHTML.

arr.map() will return an array.

“this” is the new array created by arr.map().

It should not be assigned within the empty callback function (the function should be empty)

It is worded a bit odd with how it talks about creating a new array.

As said, the “new array” is what map returns. That return should be assigned using += to playerCards.innerHTML

You have done something like this before in the music player challenge (with some differences).


An example, just in case the syntax asked for is totally unclear.

someElement.innerHTML += someArray.map(() => {})
1 Like

thanks everyone. i finally figured it out. i was struggling to remember that you can set an empty function equal to an element. that still seems weird to me. i don’t fully understand it but i think i need to just accept the idea and move on lol

Also, it would be very very very nice if the instructions alluded to the fact that the map array is not going to stay empty, that in the following steps we are going to populate the empty callback function. it just seems weird and bad code to set up an element equal to an empty callback function.

I don’t understand what you mean, a function can’t be equal to an element

Not really sure what that means either.

If the map callback is empty it returns undefined so it is returning an array where each element is undefined.

const returnValue = [1, 2, 3].map(() => {});
console.log(returnValue); // [undefined, undefined, undefined]

Unlike if it actually did something:

const returnValue = [1, 2, 3].map((el) => el * 2);
console.log(returnValue); // [2, 4, 6]

someElement.innerHTML += someArray.map(() => {})

yet here we are

you are not setting a function equal to an element there, I don’t understand what you mean