Skip to content

Commit e18e861

Browse files
committed
implement contains
1 parent 2385a98 commit e18e861

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

‎Sprint-2/implement/contains.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1-
function contains() {}
1+
function contains(object, property) {
2+
if (object === null || typeof object !== "object" || Array.isArray(object)) {
3+
return false;
4+
}
5+
6+
return object.hasOwnProperty(property);
7+
}
28

39
module.exports = contains;
10+
11+
// Implement a function called contains that checks an object contains a
12+
// particular property
13+
14+
// E.g. contains({a: 1, b: 2}, 'a') // returns true
15+
// as the object contains a key of 'a'
16+
17+
// E.g. contains({a: 1, b: 2}, 'c') // returns false
18+
// as the object doesn't contains a key of 'c'
19+
// */

0 commit comments

Comments
 (0)