Skip to content

Instantly share code, notes, and snippets.

@codetricity
Last active November 1, 2018 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codetricity/7af69bcdf206ff6c3caf855b3ffbf6fd to your computer and use it in GitHub Desktop.
Save codetricity/7af69bcdf206ff6c3caf855b3ffbf6fd to your computer and use it in GitHub Desktop.
d3 rainfall lessons
d3.csv('data/rainfall-by-state.csv').then(data => {
data.forEach(stateData => {
stateData.rainfall = +stateData.rainfall;
const checkChar = /^[A-Z]/;
for (let i = 0; i < 5; i++) {
if (checkChar.test(stateData.state)) {
console.log('found capital letter');
break;
} else {
stateData.state = stateData.state.substring(1);
}
}
});
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment