  ## Resources

1. CoderByte challenge

## Question

Have the function FindIntersection(strArr) read the array of strings stored in strArr which will contain 2 elements: the first element will represent a list of comma-separated numbers sorted in ascending order, the second element will represent a second list of comma-separated numbers (also sorted). Your goal is to return a comma-separated string containing the numbers that occur in elements of strArr in sorted order. If there is no intersection, return the string false.

For example: if strArr contains ["1, 3, 4, 7, 13", "1, 2, 4, 13, 15"] the output should return "1,4,13" because those numbers appear in both strings. The array given will not be empty, and each string inside the array will be of numbers sorted in ascending order and may contain negative numbers.

## Examples

```.css-e69dqy{position:relative;z-index:0;}.css-qq5p7o{padding:var(--chakra-space-5);border-radius:8px;margin-top:var(--chakra-space-8);margin-bottom:var(--chakra-space-8);background:#011627;-webkit-padding-start:0px;padding-inline-start:0px;-webkit-padding-end:0px;padding-inline-end:0px;overflow:hidden;}Input: ["1, 3, 4, 7, 13", "1, 2, 4, 13, 15"]
```Input: ["1, 3, 9, 10, 17, 18", "1, 4, 9, 10"]
Output: 1,9,10```

Worst case:

```function FindIntersection(strArr) {
// code goes here
const [a, b] = strArr;
const nunbers = a.split(',').filter(el => b.split(',').includes(el));
return numbers.length ? numbers.map(el => el.trim()).join(',') : false;
}

// keep this function call here

Best case:

```function FindIntersection(strArr) {
// code goes here
const [a, b] = strArr.map(s => s.split(', '));
const numMap = {};
const numbers = [];

for (let number of a) {
numMap[number] = number;
}

for (let number of b) {
if (numMap[number]) {
numbers.push(number);
}
}

return numbers.length ? numbers.join(',') : false;
}```