After 15 minutes - http://jsfiddle.net/NSdyg/
Another 5 to make it work (almost) - http://jsfiddle.net/NSdyg/1/
I don't do much JS (as you can likely tell) but found the task approachable. I think that the low barrier to entry is a good thing for an interview question.
My approach is described in the comments. I started by writing it out and then went from there.