I highly recommend familiarizing yourself with your browser’s debugger. Anytime you don’t understand why the code is doing what it is, you can step through it line-by-line and inspect values to see where things start to go astray. It’s not always a magic bullet, but it’s a powerful tool for understanding and fixing code. Like here, you could have seen pretty quickly that d3.csv returned a Promise object rather than the expected array.
You can use your debugger within Observable, too. Add a debugger statement to a cell, pop open the debugger, then hit the play button or Shift-Enter. For example:
{
debugger;
for (let i = 0; i < 10; ++i) {
yield i;
}
}