I\'m experiencing some weird behavior with a JavaScript function which I think may be a syntax issue/misunderstanding on my part as to how JavaScript "returns" fun