Home > Back-end >  Intersection of a number on string using underscore library
Intersection of a number on string using underscore library

Time:12-09

I have two inputs one is this.

Data1: 1
Data 2: [1]

But if i use ._ like this.

_.intersection(data2,data1)

It is giving me result like this.

Intersection: []

What am i doing wrong here?

CodePudding user response:

the .intersection function seems to require array as parameters, you are passing first value as a number, try passing as array like:

...
data1 = 1;
data2 = [1];
_.intersection(data2,[data1]);
...
  • Related