// Fisher-Yates algorithm const cards = ['A', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K']; shuffle(cards); console.log(cards); function shuffle(array){ for(let i = array.length - 1; i > 0; i--){ const random = Math.floor(Math.random() * (i + 1)); [array[i], array[random]] = [array[random], array[i]]; } }
@-_SleepAndEat_-7 ай бұрын
Bro can you do Kali Linux ?
@allangoes24747 ай бұрын
helped me a lot! thanks for the tutorial
@AndreaDAuria12 ай бұрын
Beautiful ❤
@PojiEste Жыл бұрын
Enjoy the show☺
@himynameisidiot5 ай бұрын
oh my god bro this is so helpful! thanks for saving me 25 lines of spaghetti code!
@professorpoke3 ай бұрын
TIP: If (for some reason) you want to make sure that no number ends up in the place it was in before the shuffle, do this minor change in the code. ``` function shuffle(array) { for(let i = array.length - 1; i > 0; i--) { const random = Math.floor(Math.random() * i); // `i` instead of `i+1` [array[i], array[random]] = [array[random], array[i]]; } } ```
@jubba9263 Жыл бұрын
Just a random comment to shuffle the KZbin algorithm🎉
@educationalbro1611 Жыл бұрын
bro i am following your previous js playlist should i continue that or should i continue from this series
@GarethFlandro4 ай бұрын
probably this one is better (but you might be done with both by now lol)
@Nedigital__lol Жыл бұрын
Day 3 ends…. I’ll go check more about reduce()
@245B Жыл бұрын
Could you create a tutorial about Rust programming language?
@FatsFalafel3 ай бұрын
How is this more efficient than the first way? Just because of the built in algorithm for the sort() method?
@PojiEste Жыл бұрын
Bro request course lua
@ItsLolwethu Жыл бұрын
Yes Javascript🃏
@yuvrajsingh-fz7hdАй бұрын
best
@Blitz61wasd Жыл бұрын
What kind of project we use this on?
@professorpoke3 ай бұрын
May be some card game, or anything where you need to shuffle an array to create a different/random scenario everytime.
@90XANAS Жыл бұрын
bro please elaborate a lil bit more of JS topics...