Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 11/02/2018 in all areas

  1. 1 point
    You could replace that filter function with Array.splice. Generate the random number, use splice to remove and return the removed element, and then push the element onto the other array. function selectCubes(gates) { var cubes = ['cube_one', 'cube_two', 'cube_three', 'cube_four', 'cube_five', 'cube_six', 'cube_seven']; var selectedCubes = []; while (selectedCubes.length < gates) { selectedCubes.push(cubes.splice(Math.floor(Math.random()*cubes.length), 1)[0]); } return selectedCubes; }
×