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.
2 parents 90afe10 + cd0a557 commit db402f7Copy full SHA for db402f7
14_contains/solution/contains-solution.js
@@ -1,11 +1,13 @@
1
-const contains = function(current, search) {
2
- if (Object.values(current).includes(search)) return true;
+const contains = function(obj, searchValue) {
+ const values = Object.values(obj);
3
+ if (values.includes(searchValue)) return true;
4
- for (const nestedObject of Object.values(current).filter((value) => typeof value === 'object')) {
5
- return contains(nestedObject, search)
+ const nestedObjects = values.filter((value) => typeof value === 'object');
6
+ for (const nestedObject of nestedObjects) {
7
+ return contains(nestedObject, searchValue);
8
}
-
- return false
9
+
10
+ return false;
11
};
12
13
// Do not edit below this line
0 commit comments