Created
January 15, 2021 23:28
-
-
Save bqmackay/4c91ed8c6e18c445046e02099358705e to your computer and use it in GitHub Desktop.
Example of good and bad comments
This file contains 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
//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