Removing decimals with .toFixed(0) Error


#1

Trying to make sure the variable saleprice doesn’t have any decimal numbers. So Im rounding it.
Have been using the exact same method and it worked perfectly.
Now it is giving me this:
[error] Error in runEval code: Invalid or unexpected token

Tried different ways to write the command, like storedVars[‘saleprice’].toFixed(0), tried the Round method. The mystery is that I have the same code in the other script and it works perfectly.
The code :
{
“CreationDate”: “2018-11-4”,
“Commands”: [
{
“Command”: “storeEval”,
“Target”: “2650”,
“Value”: “saleprice”
},
{
“Command”: “storeEval”,
“Target”: “${saleprice}.toFixed(0)”,
“Value”: “saleprice”
}
]
}


#2

I guess “toFixed” thinks the input is a string. This works:

parseInt (${saleprice}).toFixed(2);

But of course, just parseInt will be enough for removing the decimals:

parseInt (${saleprice});

{
  "CreationDate": "2018-11-4",
  "Commands": [
    {
      "Command": "store",
      "Target": "2650.123",
      "Value": "s1"
    },
    {
      "Command": "storeEval",
      "Target": "parseInt (${s1}).toFixed(2);",
      "Value": "s2"
    },
    {
      "Command": "echo",
      "Target": "before=${s1},  after=${s2}, ",
      "Value": ""
    }
  ]
}