jeudi 24 janvier 2019

Randomize item from Array with exclude specific item in JavaScript

I wonder if there is any option to randomize an item from array and exclude specific item.

e.g: array=["a","-","b","c","d"] I want randomize letter from this array but not "-" char.

I know I can do a while loop and check if its the unwanted item. but its not a robust code, and may cause a lot of bugs.

I know I can put them into a new array but its wont help me for my needs.

Maybe its not possible but I just want to be sure. I will be grateful for any help Thank!




Aucun commentaire:

Enregistrer un commentaire