console.clear() var letter2count = d3.nest() .key(d => d) .rollup(d => d.length) .object('adamrichardzoia'.split('')) // .object('adamzoia'.split('')) d3.loadData('words.csv', 'yob-2016.csv', (err, res) => { words = res[0] names = res[1] var validWords = words.filter(d => { if (!d.word.includes('z')) return var byLetter = d3.nestBy(d.word.split(''), d => d) return byLetter.every(d => d.length <= letter2count[d.key]) }) d3.select('.words').html('') .appendMany('span', _.sortBy(validWords, d => d.word.length)) .text(d => ' ' + d.word) .st({marginRight: 10, width: 80, display: 'inline-block'}) var validWords = names.filter(d => { if (!d.word.includes('z')) return d.word = d.word.toLowerCase() var byLetter = d3.nestBy(d.word.split(''), d => d) return byLetter.every(d => d.length <= letter2count[d.key]) }) d3.select('.names').html('') .appendMany('span', _.sortBy(validWords, d => d.word.length)) .text(d => ' ' + d.word) .st({marginRight: 10, width: 80, display: 'inline-block'}) })