Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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
- // **********************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement