Skip to content

ahadb/last-of-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

last-of-array

Return the last element in an array. Is tested.

Overview

The module can be used when you need a function that returns the last element of an array

Installing

npm i last-of-array --save-dev

Usage

Simply require the last-of-array module. The export function can be used in any module you desire:

const last = require('last-of-array');

last([1,100,1000); // 1
last([['Ahad', 12, 10000], 12, 'Three', true]); // ['Ahad', 12, 10000]

TODO

  • add more tests

Tests

npm test

Also supports the standards JavaScript library, configure as follows:

"standard": {
    "ignore": [
      "/test/test.js",
      "app.js"
    ]
  }
last([1,2,3,4,5]);                      // ==> returns a number, 5
last([[1,2,3,4,5,'Ahad']);              // ==> returns a string, 'Ahad'
last([[13,2234,32,43,5.2223,1,[2e10]])  // ==> returns only the last element, an array: 2e10

Related Modules

Contributing

Feel free to file an issue or bug.

About

Return the last element in an array

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors