- Joined
- Jun 15, 2014
- Messages
- 240
- Reaction score
- 41
- First Language
- English Spanish
- Primarily Uses
Hi all!
Im super new at javascript. I created an array and I want to know which index hold the highest number.
I got this code:
When I try it on a javascript sandbox, it does what I want but If I try it on the RPGMAKER MV console, it sayts unexpected token "=>".
Im guessing I cant just run that code on the console? or maybe because im in version 1.51 that I cant run that specific code?
Any how, any help to achieve what I need would be appretiated.
Thanks!
Im super new at javascript. I created an array and I want to know which index hold the highest number.
I got this code:
Code:
var a = [0, 21, 22, 7];
var indexOfMaxValue = a.reduce((iMax, x, i, arr) => x > arr[iMax] ? i : iMax, 0);
console.log("indexOfMaxValue = " + indexOfMaxValue);
Im guessing I cant just run that code on the console? or maybe because im in version 1.51 that I cant run that specific code?
Any how, any help to achieve what I need would be appretiated.
Thanks!
