Would someone please explain the following:
Im following Dan Abramov's lectures & doing the exercises.
The code works fine, however the tests fail when the following particular function is written with curly brackets **{ }**
.
case 'toggleTodo' :
return (
state.map( (one) => {
oneTodo( one, action )
})
);
The same code works fine without curly brackets.
case 'toggleTodo' :
return (
state.map( (one) =>
oneTodo( one, action )
)
);
Here is the JsBin. Please refer to line 31 onwards.
is equal to:
see the return statement
The pair of braces forms a block, containing a list of statements. You need to use a
return
statement explicitly to make the function return something.If you omit the braces, the arrow function has a concise body, which consists solely of a single expression whose result will implicitly become the return value of the function.