Last active
August 12, 2019 07:46
-
-
Save YannMjl/1bb258ff93d20b52ca2b1378f65872d6 to your computer and use it in GitHub Desktop.
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
| // get the lenght of an array list | |
| var fruits = ["Banana", "Orange", "Apple", "Mango"]; | |
| var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; | |
| function getListLenght(list) { | |
| var _lenght = list.length; | |
| return _lenght; | |
| } | |
| console.log('The number of item in list is: ', getListLenght(fruits)); // 4 | |
| console.log('The number of item in list is: ', getListLenght(numbers)); // 14 | |
| // ********************************************************************************** | |
| // - In this case the run time of getListLenght is costant: O(1) | |
| // - It'll take the same time to run no matter the number of item in the array list | |
| // ********************************************************************************** |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment