Skip to content

Commit ad17b3e

Browse files
adding 61
1 parent 85c6df5 commit ad17b3e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

Diff for: README.md

+36
Original file line numberDiff line numberDiff line change
@@ -2285,3 +2285,39 @@ const sortByLength = (arr) => {
22852285
22862286
---
22872287
**[⬆ Back to Top](#header)**
2288+
2289+
2290+
2291+
##### 62. A value is omnipresent if it exists in every subarray inside the main array. Create a function that determines whether an input value is omnipresent for a given array.Create a function that takes an array of strings and return an array, sorted from shortest to longest.
2292+
2293+
2294+
```js
2295+
const isOmnipresent = (arr, val) =>{
2296+
//Write Your solution Here
2297+
};
2298+
2299+
console.log(isOmnipresent([[1, 1], [1, 3], [5, 1], [6, 1]], 1)); // true
2300+
2301+
console.log(isOmnipresent([[1, 1], [1, 3], [5, 1], [6, 1]], 6)); // false
2302+
2303+
console.log(isOmnipresent([[5], [5], [5], [6, 5]], 5)); // true
2304+
2305+
console.log(isOmnipresent([[5], [5], [5], [6, 5]], 6)); //false
2306+
```
2307+
2308+
<details><summary style="cursor:pointer">Solution</summary>
2309+
2310+
```js
2311+
const isOmnipresent = (arr, val) => {
2312+
for (i in arr){
2313+
for (i in arr[i]){
2314+
return arr[i].includes(val)
2315+
}
2316+
}
2317+
}
2318+
```
2319+
2320+
</details>
2321+
2322+
---
2323+
**[⬆ Back to Top](#header)**

0 commit comments

Comments
 (0)