How do I want to do this, anyway?
Opened this issue · 3 comments
Writing this all down to get it out of my head; once it's out, I'll be less likely to spin more and more complicated scenarios without actually writing code (i.e. wasting time).
What I want to do: take a list of movies (say in alpha order) and shuffle them; then assign the new-order-of-movies dates from a list of dates in linear (ascending) order.
What I'll need:
- a list of movies
- a list of dates
- an object "at the end" where the
keys
are the dates and thevalues
are the movie titles
Versions, passes, iterations (i.e. practicing, warming-up)
- make a short, sample array; display its original order; shuffle it; spit out the new order.
- shuffle an array of numbers (like 1-5), then assign the newly ordered numbers as the key in an object whose key-value pairs are order # and movie title
- … possibly ☝️ is the final version, but we'll see.
First version is up: #3
One note: there's nothing yet protecting against just carrying on clicking the button over and over, but instead of disabling it, maybe subsequent clicks could continue to reorder the movies (vs. appending the same list forever [since it's already shuffled by the time that button's clicked]).
💡 collect the movies in an object along with who chose them? To what end, to what end… So maybe the final output could be the movies paired with dates and also show who chose what. 🤔
const movies = {
"Jaws": "L",
"Wonder Woman": "K"
}
What if I… use the simple shuffle function on the movie titles and then "just" for…of
through the resulting array. Inside that for…of
, I would populate a new object where the key is the current movie title (i.e. index) and the value is the current date (from the summerDates
array)…