Skip to content

Instantly share code, notes, and snippets.

@spanuska
Last active April 12, 2016 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spanuska/f9007e79cf31d058bdf8823c31ee174f to your computer and use it in GitHub Desktop.
Save spanuska/f9007e79cf31d058bdf8823c31ee174f to your computer and use it in GitHub Desktop.
function nth(list, index) {
for (var node = list; node; node = node.rest) {
if (index == 0) {
return (node.value || undefined);
} else {
nth(node.rest, index--)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment