Jump to content

SweatyWrangler

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

About SweatyWrangler

  • Rank
    Newbie
  1. What's the issue? The example I am referring to is the Fisher Yates implementation on this page: https://www.w3schools.com/js/js_array_sort.asp This is the code in question: var points = [40, 100, 1, 5, 25, 10]; for (i = points.length -1; i > 0; i--) { j = Math.floor(Math.random() * i) k = points[i] points[i] = points[j] points[j] = k } If you run the example you will see the elements of the array shuffle around and everything will seem to be working as expected. The issue is subtle. With the above code block the element in the last position of the array can never
×
×
  • Create New...