Home > Enterprise >  i need help troubleshooting this error im getting with this javascript code
i need help troubleshooting this error im getting with this javascript code

Time:04-28

This is my code:

var array = process.argv.slice(2);


var min = Number.MIN_VALUE;
var max = Number.MAX_VALUE;


min = Math.min(...array);
max = Math.max(...array);


console.log("Maximum number is: ", max);
console.log("Minimum number is: ", min);

When I run it it errors:

min = Math.min(...array);
               ^^^

SyntaxError: Unexpected token ...

I'm using codio as my IDE.

CodePudding user response:

It's probably because of the node version is too old, try to update the node version.

It's working perfectly fine in my environment.

enter image description here

CodePudding user response:

Check you array and confirm it whether it really is an array.

  • Related