-2

I am trying to sort a Javascript by Assets_%

    CLH.US
    Assets_% : 0.57698
    Code : "CLH"
    Country: "United States"

allHoldings.sort((a,b) => a.Assets_% - b.Assets_% );

This is giving me an "Expression Expected" error, which I believe is being caused by the % at the end.

Any idea how to resolve this?

Justin
  • 297
  • 1
  • 2
  • 10

1 Answers1

-2

% is a special character, so you'll need to use bracket notation.

allHoldings.sort((a,b) => a['Assets_%'] - b['Assets_%'] );

xdumaine
  • 10,096
  • 6
  • 62
  • 103