Skip to content

Commit a12b69a

Browse files
authored
Create searchObjInArray.js
1 parent c094155 commit a12b69a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Find a value in an array of objects in Javascript
2+
/**
3+
*
4+
* @param {String} value
5+
* @param {String} key
6+
* @param {Array} arr
7+
* @returns item {Object}
8+
*/
9+
export const searchObjInArray = (value, key, arr) => {
10+
for (let i = 0; i < arr.length; i++) {
11+
if (arr[i][key] === value) {
12+
return arr[i];
13+
}
14+
}
15+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy