Created
April 1, 2018 03:58
-
-
Save MickeyKay/eaec0af51e4a6b75be6603aa1ac1150f to your computer and use it in GitHub Desktop.
Nested for loop example (better)
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
var list = ['SoMe', 'hUgE', 'aRrAy', '...']; | |
// Helper functions | |
function reverseText(text) { | |
// A | |
// big | |
// chunk | |
// of | |
// code | |
// that | |
// reverses | |
// text | |
} | |
function capitalizeText(text) { | |
// A | |
// big | |
// chunk | |
// of | |
// code | |
// that | |
// capitalizes | |
// text | |
} | |
function lowercaseText(text) { | |
// A | |
// big | |
// chunk | |
// of | |
// code | |
// that | |
// lowercases | |
// text | |
} | |
// Main function (much cleaner, right?) | |
function reverseAndCapitalizeOrLowercase(list) { | |
list.forEach(function(text) { | |
var reversedText = reverseText(text); | |
if (text.length > 3) { | |
capitalizeText(text) | |
} else { | |
lowercaseText(text) | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment