Skip to content

一次 for 循环遍历就可以了 #604

Description

@xiao-tiger
function getIndex(arr){
  let index = -1
  let minV = Infinity
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] > 0 && arr[i] < minV) {
      minV = arr[i]
      index = i
    }
  }

  return index;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions