orderd-array-remove

1.1.0 • Public • Published

orderd-array-remove

Removed an element from array by keeping order of elements inside array

Install

$ npm install --save orderd-array-remove

Example

var remove = require('orderd-array-remove');
 
console.log(remove([1, 2, 3, 4, 5], 5));
// -> [1, 2, 4, 5]

Explination

In case the element not found in the list then the function returns an original array

var remove = require('orderd-array-remove');
 
console.log(remove([1, 2, 3, 4, 5], 10));
// -> [1, 2, 3, 4, 5]

The order need to be maintained so the particular element is searched by indexOf and removed the element by splice

require('orderd-array-remove')(array, element)

Arguments:

  • array: list
  • element: the element that need to be removed

Returns: Returns the updated array after removal of the element

License

© 2016 Vikram Jadhav. MIT License

Package Sidebar

Install

npm i orderd-array-remove

Weekly Downloads

1

Version

1.1.0

License

MIT

Last publish

Collaborators

  • vikramcse