Skip to content

Commit 59c72d3

Browse files
committed
use Object.hasOwn instead of in
1 parent 0cdfa17 commit 59c72d3

1 file changed

Lines changed: 2 additions & 14 deletions

File tree

Sprint-2/implement/contains.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
11
function contains(obj, prop) {
2-
if (obj === null) {
2+
if (obj === null || typeof obj !== "object" || Array.isArray(obj)) {
33
return false;
44
}
55

6-
if (typeof obj !== "object") {
7-
return false;
8-
}
9-
10-
if (Array.isArray(obj)) {
11-
return false;
12-
}
13-
14-
if (prop in obj) {
15-
return true;
16-
} else {
17-
return false;
18-
}
6+
return Object.hasOwn(obj, prop);
197
}
208

219
module.exports = contains;

0 commit comments

Comments
 (0)