Sorting visualizers are a genre. This one is different in one way that matters: the algorithm code has zero knowledge of the DOM. Bubble, Insertion, Merge, and Quick Sort are plain generator functions that yield at every comparison and swap. The animation driver calls .next() on a timer and updates bars. Changing "algorithm" means swapping the generator. Nothing else changes.
Why generators?
The usual approach: mix the algorithm and the DOM in a single function, using async/await + sleep() to pause.
// the common pattern — tightly coupled
async function bubbleSort(bars) {









