I'm trying to extend the JS Number prototype to include a Ruby-esque ".times" method (the merits of this pursuit are an issue for another time).

Here is my code:

```
Number.prototype.times = function(doThis) {
  val = +this;
  while (val > 0 ) {
    doThis();
    val--;
  }
}

```

If I try 

`5..times(console.log(1));` 

I get the following output:

```
foo
TypeError: undefined is not a function (evaluating 'doThis()')

```

Why does the loop work on the first iteration and fail on the second?

(note: the goal is to make the Number prototype extension such that calling it is highly expressive, intuitive, and reads more like natural language, like Ruby's [.times](http://ruby-doc.org/core-2.2.2/Integer.html#method-i-times) method.)