|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
582 bytes
|
| Line | |
|---|
| 1 | export default function maxIndex(values, valueof) {
|
|---|
| 2 | let max;
|
|---|
| 3 | let maxIndex = -1;
|
|---|
| 4 | let index = -1;
|
|---|
| 5 | if (valueof === undefined) {
|
|---|
| 6 | for (const value of values) {
|
|---|
| 7 | ++index;
|
|---|
| 8 | if (value != null
|
|---|
| 9 | && (max < value || (max === undefined && value >= value))) {
|
|---|
| 10 | max = value, maxIndex = index;
|
|---|
| 11 | }
|
|---|
| 12 | }
|
|---|
| 13 | } else {
|
|---|
| 14 | for (let value of values) {
|
|---|
| 15 | if ((value = valueof(value, ++index, values)) != null
|
|---|
| 16 | && (max < value || (max === undefined && value >= value))) {
|
|---|
| 17 | max = value, maxIndex = index;
|
|---|
| 18 | }
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 | return maxIndex;
|
|---|
| 22 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.