VPY
VPY

Reputation: 463

Javascript Map Function compile error

I have the following array of objects (as shown below) as graphdatalogs

enter image description here

I am trying to create a new array of objects called graphdata with x and y as properties from graphdatalogs

I tried the following javascript map method but I am getting compile error as shown below.

return this.state.graphdataLogs.rows._array.map( 
    (ae) => (graphdata.push(x:ae.logstringdate.substring(4,10),y:metricweight));
    );

enter image description here

Error Message

Parsing error: Unexpected token, expected , (Fatal)

Can someone let me know what I am doing wrong ?

Upvotes: 0

Views: 108

Answers (1)

klugjo
klugjo

Reputation: 20885

You forgot the curly braces

return this.state.graphdataLogs.rows._array.map( 
    (ae) => (graphdata.push({x:ae.logstringdate.substring(4,10), y:metricweight}));
);

Upvotes: 2

Related Questions