diff --git a/README.md b/README.md index 57433ebb1..e8088ff33 100644 --- a/README.md +++ b/README.md @@ -512,7 +512,7 @@ Use array destructuring to swap values between two variables. ### Tail of list -Return `arr.slice(1)`. +Return `arr.slice(1)` if the array's `length` is more than `1`, otherwise return the whole array. ```js const tail = arr => arr.length > 1 ? arr.slice(1) : arr; diff --git a/snippets/tail-of-list.md b/snippets/tail-of-list.md index cecca8e8e..d0c9681c3 100644 --- a/snippets/tail-of-list.md +++ b/snippets/tail-of-list.md @@ -1,6 +1,6 @@ ### Tail of list -Return `arr.slice(1)`. +Return `arr.slice(1)` if the array's `length` is more than `1`, otherwise return the whole array. ```js const tail = arr => arr.length > 1 ? arr.slice(1) : arr;