![]() |
|
|||
|
On Sep 23, 8:50*am, Oltmans <rolf.oltm...@gmail.com> wrote:
> Hi guys, > I'm learning JavaScript and I need some puzzles that can make me a > better JavaScript programmer. [...] > > [...] please recommend programs > that you wish you had done earlier to understand internals in a better > way. Thanks in advance. One of the first Javascript programs that I wrote lives here: http://webstervanrobot.com/ (only tested on Firefox) The program implements a small programming language on top of Javascript that allows a robot to move around a grid of streets and avenues. It got me acquainted with the following concepts: creating objects manipulating DOM parsing strings implementing data structures responding to events setting up callbacks and responding to them variable scoping (this, var, etc.) cross-browser pain (which I have punted on so far) If you're learning Javascript, this might be a fun program to hack on, because it's all self-contained and not tied to any domain, and I'm hoping to make it a useful program. It really is a "Javascript program," as opposed to code that lives within a larger system, for better or worse. Some challenges: 1) Make it work on a browser other than Firefox. 2) Change the world to be rendered on a canvas instead of tables. 3) Add scrolling to the world. 4) Add new capabilities for the robot. 5) Add new syntax to the programming language. 6) Simply play around with the code, try to restructure it to your liking. 7) Get the program to have a mode where you can click on it to see the internal data structures that define the world. Yes, I'm subversively asking for help with my program, but the program was written with the intention of helping people learn Javascript (and programming in general). It's free software. Cheers, Steve http://webstervanrobot.com/ |
|
|||
|
On Sep 23, 5:50*pm, Oltmans <rolf.oltm...@gmail.com> wrote:
> > Please recommend anything. Have you seen Douglas Crockford's videos already ? http://developer.yahoo.com/yui/theater/ -- Jorge. |
|
|||
|
On Sep 27, 3:08*am, Douglas Crockford <nos...@sbcglobal.net> wrote:
> Oltmans wrote: > > Hi guys, > > I'm learning JavaScript and I need some puzzles that can make me a > > better JavaScript programmer. > > Dmitri showed me this one: > > Define function add such that > > * * *add(3)(4) > > returns 7. javascript:alert((function add (p) { var a=p; return function (p) { return a+p } })(3)(4)) -- Jorge |
|
|||
|
On 2008-09-27 03:18, Jorge wrote:
>> Define function add such that> >> add(3)(4) >> returns 7. > > javascript:alert((function add (p) { var a=p; return function (p) > { return a+p } })(3)(4)) You don't need to create an extra variable. function add (first) { return function (second) { return first + second; } } But hey! Don't spoil the fun for the OP by posting the solution! @Douglas: I'd also appreciate more puzzles if you know any. This kind of (simple but interesting) problem is a godsend when you're teaching kids. The only thing I've seen recently that comes close to a puzzle is this website: http://parentnode.org/static/challange2.html You need to enter the correct password, that's all. No rewards :-) It's not pretty, rather the opposite, but if you like obfuscation, it might be interesting. Syntax highlighting helps. - Conrad |
|
|||
|
On Sep 27, 4:07*am, Conrad Lender <crlen...@yahoo.com> wrote:
> On 2008-09-27 03:18, Jorge wrote: > > >> Define function add such that> > >> * * *add(3)(4) > >> returns 7. > > > javascript:alert((function add (p) { var a=p; return function (p) > > { return a+p } })(3)(4)) > > You don't need to create an extra variable. > > function add (first) { > * * return function (second) { > * * * * return first + second; > * * } > > } Damn it! (but that took you an hour hehe) -- Jorge. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|