replace-item-in-array

1.0.5 • Public • Published

About

Replace first of the search element with the replacement other element. This function returns boolean.

Param Type Description
First Array Your array
Second Any Searched element
Third Any Replaced element

Example:

import replaceItemInArray from 'replace-item-in-array'

const myArray = ["red","black","yellow","white","blue"]
const search = "yellow"
const replace = "green"

const result = replaceItemInArray(myArray, search, replace)
console.log(result)
// true
console.log(myArray)
// ["red","black","green","white","blue"]

Readme

Keywords

none

Package Sidebar

Install

npm i replace-item-in-array

Weekly Downloads

22

Version

1.0.5

License

MIT

Unpacked Size

4.58 kB

Total Files

9

Last publish

Collaborators

  • gothic-prince