0

Hi how can i randomnize the index of this array?

var arr = new Array("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20");

i want to return the index of the array randomnly. Any help?

Edited by techyworld

2
Contributors
4
Replies
7
Views
4 Years
Discussion Span
Last Post by techyworld
0

I want it to generate the number only one.Fisher-Yates will do it? Because next time it regenerates, it should not give me the number it produced at start

0

@techyworld

I want it to generate the number only one.Fisher-Yates will do it? Because next time it regenerates, it should not give me the number it produced at start

The link I provide is to generate random arrays so every numbers appears in the array.

You want to generate a random number in the array but only one number appear? In order to do that you need to create a if & else statement.

0

Nope lets say i have an array of 5 elements. index of array = 0,1,2,3,4

it generates a random index like 3. after generating this number, it should delete index 3 in the array. so next time it regenerates it has only this index left = 0,1,2,4. the third element is removed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.