SEO Forums: Your seo discussion forum  
Welcome, Unregistered.
You last visited: Today at 09:30 PM
Tags:



Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 09-25-2008, 04:55 AM
showellshowell@gmail.com
Guest
 
Posts: n/a
Default Re: Need some JavaScript puzzles

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/

Reply With Quote


  #12 (permalink)  
Old 09-25-2008, 11:08 PM
Jorge
Guest
 
Posts: n/a
Default Re: Need some JavaScript puzzles

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.
Reply With Quote


  #13 (permalink)  
Old 09-27-2008, 07:24 AM
Douglas Crockford
Guest
 
Posts: n/a
Default Re: Need some JavaScript puzzles

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.
Reply With Quote


  #14 (permalink)  
Old 09-27-2008, 07:24 AM
Jorge
Guest
 
Posts: n/a
Default Re: Need some JavaScript puzzles

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
Reply With Quote


  #15 (permalink)  
Old 09-27-2008, 07:24 AM
Conrad Lender
Guest
 
Posts: n/a
Default Re: Need some JavaScript puzzles

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
Reply With Quote


  #16 (permalink)  
Old 09-27-2008, 07:24 AM
Jorge
Guest
 
Posts: n/a
Default Re: Need some JavaScript puzzles

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.
Reply With Quote


Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:30 PM.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Great Seo Blog at SEONOTEPAD.COM