Can this coffeescripts method be simplified? I'm new to coffeescripts. Can the getSum method be simplified more? Thanks

MyObject =
  checkCondition: (num) -&gt;
    return true if num is 5

  getSum: (num) -&gt;
    total = 0
    total += i for i in [1..num] when @checkCondition i
    total


I tried removing the last total but coffeescripts compiler goes nut :-/

Any help greatly appreciate.
First, return true if num is 5 is the same as just num is 5.
Then, you can convert the explicit loop into a reduce (you can read about it in Wikipedia or MDN): 

MyObject =
  checkCondition: (num) -&gt; num is 5

  getSum: (num) -&gt;
    [0..num].reduce (x,y) =&gt;
        if @checkCondition y then x + y else x


Note =&gt; instead of plain -&gt; after (x,y). This is fat arrow, it prevents the capture of @ the inside function.