Journal entry

Geekpulp

Consider the following code: [code] function danceLikeNoOnesWatching( person ) { if ( person.danceMoves === “amazing” ) { return false; } else { return true; } } [/code]

Looks good right? It’s logical and easy to understand, just your standard if statement. All true, but over the course of an entire project you’ll make a lot of considtional statements like this and using 5 lines of code when 1 will do can create some serious size increases to your code. To reduce the codes size, just return the output of the conditional like this: [code] function danceLikeNoOnesWatching( person ) { return person.danceMoves === “amazing”; } [/code]

Simpler, still easy to understand and now light weight.