Created
February 5, 2014 14:53
-
-
Save slopeofhope81/8825339 to your computer and use it in GitHub Desktop.
Write a function extractDate that takes such a paragraph as its argument, extracts the date, and returns it as a date object.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //"died 27/04/2006: Black Leclère" | |
| var p = "died 27/04/2006: Black Leclère" | |
| function extractDate(p) { | |
| function find(start, length) { | |
| return p.slice(start, start + length) | |
| } | |
| return new Date(find(11, 4), find(8, 2) - 1, find(5, 2)) | |
| } | |
| Here I used nested functions! I am starting to understand when to use nested function inside the outer function that is famously called closure! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment