From 95495bd5dc082d5b7aaae7da3af6a096b86944a6 Mon Sep 17 00:00:00 2001 From: lumosmind <12192118+lumosmind@users.noreply.github.com> Date: Tue, 29 Oct 2019 16:50:37 +0300 Subject: [PATCH] linked list must end with 'null' We need to put 'null' to end of linked list. otherwise wen we want to get last item in the linked list, it will be undefined. And this situation inconsistent with object literal definition of linked list above. --- 1-js/06-advanced-functions/01-recursion/article.md | 1 + 1 file changed, 1 insertion(+) diff --git a/1-js/06-advanced-functions/01-recursion/article.md b/1-js/06-advanced-functions/01-recursion/article.md index 3e41d432..688badb0 100644 --- a/1-js/06-advanced-functions/01-recursion/article.md +++ b/1-js/06-advanced-functions/01-recursion/article.md @@ -459,6 +459,7 @@ let list = { value: 1 }; list.next = { value: 2 }; list.next.next = { value: 3 }; list.next.next.next = { value: 4 }; +list.next.next.next.next = null; ``` Here we can even more clearer see that there are multiple objects, each one has the `value` and `next` pointing to the neighbour. The `list` variable is the first object in the chain, so following `next` pointers from it we can reach any element.