mjavascript / practical-modern-javascript

🏊 Dive into ES6 and the future of JavaScript

Home Page:https://mjavascript.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ch04: Possible error in output example of "Building Versatility Into Iterating a Playlist"

vsemozhetbyt opened this issue · comments

See last code examples in this section.

If I get this right, we get a sequence from the shuffleSongs() just once and iterate this sequence every time in the same order. So we cannot have different order inside each loop like:

// <- ['a', 'b', 'b', 'a', 'a', 'b']

Only these varians are possible:

// <- ['a', 'b', 'a', 'b', 'a', 'b']
// <- ['b', 'a', 'b', 'a', 'b', 'a']

This is correct to maintain consistency across runs. If you wanted different orders every time, you can keep calling playlist()