# Arrow function Syntax Problem

**URL:** <https://forum.codewithmosh.com/t/arrow-function-syntax-problem/9200>\
**Category:** JavaScript\
**Created:** [December 15, 2021, 6:20am UTC](https://forum.codewithmosh.com/t/arrow-function-syntax-problem/9200 "2021-12-15T06:20:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanath](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@sanath](https://forum.codewithmosh.com/u/sanath)\
**Post date:** [December 15, 2021, 6:20am UTC](https://forum.codewithmosh.com/t/arrow-function-syntax-problem/9200/1 "2021-12-15T06:20:48Z")

</div>

Arrow function syntax will be  
(a,b,c) =\> { }  
Like this right ?  
But I have seen mosh sir writing the follow code in vidly project . I didnt get why he is using paranthesis instead of flower bracket

```auto
                    <thead>

                        <tr>

                            <th>Title</th>

                            <th>Genre</th>

                            <th>Stock</th>

                            <th>Rate</th>

                        </tr>

                    </thead>

                    <tbody>

                        {this.state.movies.map((movie) => (

                            <tr>

                                <td>{movie.title}</td>

                                <td>{movie.genre.name}</td>

                                <td>{movie.numberInStock}</td>

                                <td>{movie.dailyRentalRate}</td>

                            </tr>

                        ))}

                    </tbody>

                </table>

```

Thanks in advance

---

<div class="post-metadata">

**Author:** ![TheAlbatross](https://avatars.discourse-cdn.com/v4/letter/t/c77e96/32.png) [@TheAlbatross](https://forum.codewithmosh.com/u/TheAlbatross)\
**Post date:** [December 15, 2021, 7:56am UTC](https://forum.codewithmosh.com/t/arrow-function-syntax-problem/9200/2 "2021-12-15T07:56:10Z")

</div>

You don’t have to use curly braces if the arrow function returns a single statement. Here, the JSX expression is a single statement, but since its broken up into multiple lines, it has to be put between a pair of parenthesis.

if he wanted to use curly braces, he’d have to write his code like this:

```auto
 {this.state.movies.map((movie) => { 
                       return (
                            <tr>

                                <td>{movie.title}</td>

                                <td>{movie.genre.name}</td>

                                <td>{movie.numberInStock}</td>

                                <td>{movie.dailyRentalRate}</td>

                            </tr>
                       )
               }
    )
}

```

Notice that using this syntax, we have to use a `return` statement AND wrap the JSX code between a pair of parenthesis, because its broken up into multiple lines.

Since we have a single statement, we can avoid using the curly braces as well as the `return` statement, which is what mosh is doing here.

---

<div class="post-metadata">

**Author:** ![sanath](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@sanath](https://forum.codewithmosh.com/u/sanath)\
**Post date:** [December 15, 2021, 7:57am UTC](https://forum.codewithmosh.com/t/arrow-function-syntax-problem/9200/3 "2021-12-15T07:57:59Z")

</div>

thanks my confusion got cleared
