Created
December 3, 2021 21:18
-
-
Save russelllim22/9ae356f8c0f7b6ef330dbf2275d2414d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const totalBabies = letterCounts.reduce((a, b) => a + b.count, 0); | |
const smallCounts = {letter: "other", count: 0, otherLetters: ""} | |
for(let i = 25; i>=0; i--){ | |
if(letterCounts[i].count < 0.015*totalBabies){ | |
smallCounts.otherLetters += `${letterCounts[i].letter},`; | |
smallCounts.count += letterCounts[i].count; | |
letterNames["other"] = letterNames["other"].concat(letterNames[letterCounts[i].letter]) | |
letterCounts.splice(i,1) | |
} | |
} | |
letterCounts.sort((a,b)=> d3.descending(a.count, b.count)) | |
letterCounts.push(smallCounts); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment