Create a gist now

Instantly share code, notes, and snippets.

Embed
<cfscript>
arrayOfStrings = [ 'a', 'at', 'cat', 'scat', 'catch' ];
regex = '.+at';
writeOutput( arrayOfStrings.reduce( function( result='', item ){ return len( result ) ? result : item.reFind( regex ) ? item : ''; } ) );
</cfscript>
@atuttle

This comment has been minimized.

Show comment
Hide comment
@atuttle

atuttle Aug 12, 2016

I thought about nested ternaries too but figured Adam would chastise me for it. ;)

atuttle commented Aug 12, 2016

I thought about nested ternaries too but figured Adam would chastise me for it. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment