Skip to content

Instantly share code, notes, and snippets.

@bqmackay
Created January 15, 2021 23:28
Show Gist options
  • Save bqmackay/4c91ed8c6e18c445046e02099358705e to your computer and use it in GitHub Desktop.
Save bqmackay/4c91ed8c6e18c445046e02099358705e to your computer and use it in GitHub Desktop.
Example of good and bad comments
//Bad Comment (https://improvingsoftware.com/2011/06/27/5-best-practices-for-commenting-your-code/)
// Loop through all bananas in the bunch
foreach(banana b in bunch) {
monkey.eat(b); //make the monkey eat one banana
}
//Good Comment (https://www.freecodecamp.org/news/code-comments-the-good-the-bad-and-the-ugly-be9cc65fbf83/)
function addSetEntry(set, value) {
/* Don't return `set.add` because it's not chainable in IE 11. */
set.add(value);
return set;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment