We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 461e87e commit 371eb7eCopy full SHA for 371eb7e
Sprint-2/implement/contains.js
@@ -1,3 +1,12 @@
1
-function contains() {}
+function contains(object, propertyName) {
2
+ // return false if object is null/defined or not an object
3
+ if (object == null) return false;
4
+ // typeof check + reject arrays
5
+ if (typeof object !== "object") return false;
6
+ if (Array.isArray(object)) return false;
7
+
8
+ // Use hasOwnProperty to check only own properties
9
+ return Object.prototype.hasOwnProperty.call(object, propertyName);
10
+}
11
12
module.exports = contains;
0 commit comments