As I am doing this part of the exercise,

> 
> and nth, which takes a list and a number and returns the element at the given position in the list (with zero referring to the first element) or undefined when there is no such element.
> 
> 
> 

I thought of answering it like this.:

```
function nth(list, num) {
  return listToArray(list)[num];
}

```

listToArray (reference):

```
function listToArray(list) {
  let array = [];
  for (let node = list; node; node = node.rest) {
    array.push(node.value);
  }
  return array;
}

```

Is this considered cheating? Does it affect optimization, makes the program/function run "slower"? Because it's suppose to be recursive or a while loop according to the solution and as seen on the internet.

In addition, I think there's another way of solving this but I can't wrap my head how to do it, it's implied from the hint of the exercise that the `for (let node = list; node; node = node.rest)` can be used to access the list for both of the aforementioned functions, but I can't think of a way to use it with the `nth` function. This is what I am really curious about...

Hint:

> 
> To run over a list (in listToArray and nth), a for loop specification like this can be used: `for (let node = list; node; node = node.rest)`
> 
> 
>