JavaScript Challenge: Q1

12 views
Skip to first unread message

Chris

unread,
Sep 20, 2011, 5:04:07 AM9/20/11
to Bysoft CMS
Implement a recursion function that accept two number parameters,
"start" and "end".
Then add up all the numbers between "start" and "end".
Can not invoke functions inside itself, all functions that used in
calculation should be anonymous.
For example:
var abc = function(){
// can not invoke "abc"
var result = (function(){})();
}

===== Chinese Version =====
实现一个匿名函数, 接受两个数字参数, "start" 和 "end", 把 "start" 到 "end" 之间的数 (包括自身) 相加.
不允许在函数内部调用自己, 参与运算的函数均为匿名函数:
var abc = function(){
// 不能直接调用 "abc"
var result = (function(){})();
}

Chris

unread,
Sep 20, 2011, 5:07:01 AM9/20/11
to Bysoft CMS
Sorry, I forget the hint. :-P

arguments.

This's the magic key for this question.

Chris

unread,
Oct 11, 2011, 6:42:51 AM10/11/11
to Bysoft CMS
Seems you all are busy to write the answer, so here's the answer from
me:
http://jsbin.com/ojayux/2/edit#javascript

On Sep 20, 5:04 pm, Chris <yesu...@gmail.com> wrote:

Wei dai

unread,
Oct 13, 2011, 6:31:42 AM10/13/11
to Bysoft CMS
Good!

I think we can talk about OOP in js next week.

Start from context and bind, anonymous functions and so on!

Chris

unread,
Oct 14, 2011, 2:11:33 AM10/14/11
to Bysoft CMS
What the "context" and "bind" means?

"this" keyword inside function?

"event binding"?

Wei dai

unread,
Oct 17, 2011, 11:30:09 PM10/17/11
to Bysoft CMS
Yes exactly :)
Reply all
Reply to author
Forward
0 new messages