Tell us what’s happening:
Why is it that a comma have to be followed by a space in {props.tasks.join(", ")}?And what will it be after {props.tasks.join(", ")} in my code? In other words,what happened in the process?
Your code so far
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={["green","blue","red"]} />
<h2>Tomorrow</h2>
<List tasks={["green","blue","red"]} />
{ /* change code above this line */ }
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36.
The , is the speparator that goes between the array items when you join them into a string. If you do comma, space there will be a comma and a space between them, just a comma will be just a comma
Thank U,maybe I have not explain it clearly.I wants to know what does {props.tasks.join(", ")} work for ,and why is it that my code won’t pass when I remove the space after the comma.
props.tasks is an array, you are rendering the array out as a comma-seperated string, so you use join to turn the array into a string. It doesn’t pass the test because the test expects you to have spaces after each comma