+ 1

[Solved] Trying to shuffle a word

I'm trying to shuffle a word but sometimes the word gets shuffled back to the original, why is that? https://code.sololearn.com/cMRW6QYkJWLX/?ref=app

1st Oct 2021, 6:44 PM
Tim
Tim - avatar
5 ответов
+ 2
Why not?
1st Oct 2021, 6:50 PM
JaScript
JaScript - avatar
+ 2
You can print your index and see what your algorithm do.
1st Oct 2021, 7:11 PM
JaScript
JaScript - avatar
+ 1
You are welcome.
1st Oct 2021, 7:37 PM
JaScript
JaScript - avatar
0
JaScript My apologies, I made it so the random index will never include the current index for each iteration until the index reaches 0, the letter that's not included will be swapped with the letter that's randomly chosen
1st Oct 2021, 6:54 PM
Tim
Tim - avatar
0
JaScript Will do, thanks for your response, have a good day.
1st Oct 2021, 7:12 PM
Tim
Tim - avatar