Don't understand what I'm doing wrong on Use Array.map() to Dynamically Render Elements

Challenge in question:
https://learn.freecodecamp.org/front-end-libraries/react/use-array-map-to-dynamically-render-elements

There’s only two places where you’re supposed to change code. Declaring userInput and toDoList in this.state:

                  this.state={
                    userInput=' ',
                      toDoList=[]
                        }

And defining “items:”

               const items=this.state.toDoList.map((item) => <li key={item}>{item}</li>);

The code isn’t even rendering, when I press “run the tests” I still see “Your test output will go here.” I don’t know what could be so wrong that it’s not executing at all.

Hi,

The problem you are having is not with you map function but in the state that you have declared.

You need to declare objects using colons instead of equals (assignment operator):

this.state = {
  val1: 1,
  val2: "2"
}

I think you might also have a problem with the quote marks you have used but it may just be because I copied and pasted you code. (if you surround you code with three back ticks (`) either side of your code, it will format properly on the forum)

Hope this helps :slight_smile:

D’oh! Thanks, I should’ve caught that.