React: Pass an Array as Props

React: Pass an Array as Props
0.0 0

#1

Hi!
I am stuck at the Pass an Array as Props part of the React Curriculum.
Honestly i don’t know what’s wrong with my Code.

Do you have any idea, why it isn’t working?

const List= (props) => {
  { /* change code below this line */ }
  return <p>{props.tasks.join(', ')}</p>
  { /* change code above this line */ }
};

class ToDo extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    return (
      <div>
        <h1>To Do Lists</h1>
        <h2>Today</h2>
        { /* change code below this line */ }
        <List tasks= { ["walk","dog","workout"] } />
        <h2>Tomorrow</h2>
        <List tasks= { ["hiking","watching the world cup","programming"] } />
        { /* change code above this line */ }
      </div>
    );
  }
};

#2

Your code is working. What are you talking about?


#3

Yeah, i thought so.
But it is not passing the Tests.
Thats why i am asking :slight_smile:


#4

Ok, case closed.
Changing the Browser made it possible to pass the Tests.


#5

That’s weird, it should almost always work on any modern browsers. Anyway, congrats.


#6

const List= (props) => {
{ /* change code below this line / }
return

{props.tasks.join(’,’)}


{ /
change code above this line */ }
};

class ToDo extends React.Component {
constructor(props) {
super(props);
}
render() {
return (


To Do Lists


Today


{ /* change code below this line / }
<List tasks={[“one”,“two”]} />

Tomorrow


<List tasks={[“one”,“two”,“three”]}/>
{ /
change code above this line */ }

);
}
};

i don’t know what wrong with me i cant pass this stage(i’m using safari).

But ridiculously i could pass with writer’s code.
i’m figuring it out now.


#7

the reason was white-space after ', ’ ( which is hella ridiculous)

return

{props.tasks.join(’, ‘)}

<<=== passed with this code
return

{props.tasks.join(’, ')}

<<=== failed with this code.

what’s the point?


#8

Thanks so much for mentioning that white space- I was going crazy wondering why mine wasn’t working. I suppose it is because they need to separated by a comma AND space?


#9

i don’t know .
maybe the developer forgot to mention it,
well f**k it! lol :smiley: