JS ES6 Installation

Currently I’m working on a react project and there I want to use an arrow map function for the iteration purpose. But an error comes as,

Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:\Project\src\Components\NameList\NameList.jsx: Unexpected token, expected "," (33:25)

  31 | const printArray = () => {
  32 |     return(
> 33 |         printArray.map() => {
     |                          ^
  34 |             return(
  35 |                 <NameItem 
  36 |                 name = { `${nameList[0].name.first} ${nameList[0].name.last}`}

I think the reason is I haven’t installed ES6 in my local machine. I want to know whether it is possible to install ES6 to an existing project and how to do that…

it’s just that this is not actually proper JS syntax, you can’t put an arrow symbol after invoking the function. Maybe you wanted to put something as as argument of map?

1 Like

This answer helped me to solve the problem, Thanks for the support.

I’m grateful for the explanation. I went though the challenge and solved the problem.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.