Comment on D3, Conceptually - Lesson 1Comments−vuknje13yI like the tutorial. One thing that catches my eye though is the unnecessarily complex example from the beginning: d3.selectAll('div') .text(function() { var index = Array.prototype.indexOf.call(this.parentElement.children, this); return (index % 2) == 0 ? 'Even' : 'Odd'; }); No need for calculating the index variable - it's already provided as the second argument of the function passed to the text() method: d3.selectAll('div') .text(function(d, index) { return (index % 2) == 0 ? 'Even' : 'Odd'; });
Comments
I like the tutorial. One thing that catches my eye though is the unnecessarily complex example from the beginning:
No need for calculating the index variable - it's already provided as the second argument of the function passed to the text() method: