Last active
August 12, 2016 20:13
-
-
Save mjhagen/6dbab0e60c9e347614acca6849bda309 to your computer and use it in GitHub Desktop.
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
<cfscript> | |
arrayOfStrings = [ 'a', 'at', 'cat', 'scat', 'catch' ]; | |
regex = '.+at'; | |
writeOutput( arrayOfStrings.reduce( function( result='', item ){ return len( result ) ? result : item.reFind( regex ) ? item : ''; } ) ); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I thought about nested ternaries too but figured Adam would chastise me for it. ;)