[Chartjs]-Parsing error: Unexpected token, expected ";" line 54 in .map function

1👍

For an arrow functions implicit return functionality, if you want to return an object you have to wrap that object in parentheses. Otherwise, how does it know that the curly braces are the wrapper for an object, or that they’re indicating the start of a code block?

Like so:

chartData.map((data, index) => ({
      label: 'Cars From Your Search',
      fill: false,
      backgroundColor: color[index],
      pointBorderColor: color[index],
      pointBackgroundColor: '#fff',
      pointBorderWidth: 1,
      pointHoverRadius: 5,
      pointHoverBackgroundColor: color[index],
      pointHoverBorderColor: color[index],
      pointHoverBorderWidth: 2,
      pointRadius: 5,
      pointHitRadius: 5,
      data: data
  }));

Leave a comment