Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. indexOfMax = (arr) => {
  2.  
  3. let max = arr[0]
  4. let maxIndex = 0
  5. //console.log(arr)
  6. for (var i = 1; i < arr.length; i++) {
  7. console.log(arr)
  8. console.log(i)
  9. console.log(arr[i])
  10. if (arr[i] > max) {
  11. //console.log(arr[i])
  12. maxIndex = i
  13. max = arr[i]
  14. }
  15. }
  16. console.log(maxIndex)
  17. return maxIndex
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement