Last Updated: February 25, 2016
·
1.319K
· dustinrjo

Simple Fiddle for scoping in coffeescript array loop

It can be difficult to follow variables throughout a for...in...do loop in Coffeescript, so I made this fiddle to test out the shortest syntax to loop and return conditionally only if a criteria is met.

a = [
    "bird",
    "cat",
    "moose"
]

testfunc = (b) ->
    e = ""
    for c in b
        do (c) ->
            if c is "bird"
                e = c
    return e

console.log testfunc(a)

http://jsfiddle.net/Ec245/2/