Skip to content

Commit f0e1410

Browse files
committed
update function validation checks for invalid inputs
1 parent fb46c74 commit f0e1410

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Sprint-2/implement/contains.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
function contains(obj, targetKey) {
2-
if (obj.constructor !== Object) {
2+
if (
3+
obj === null ||
4+
typeof obj !== "object" ||
5+
Array.isArray(obj) ||
6+
Object.getPrototypeOf(obj) !== Object.prototype
7+
) {
38
throw new Error("Invalid Parameter");
49
}
510
return Object.hasOwn(obj, targetKey);

0 commit comments

Comments
 (0)