A for-loop that compares two arrays looking for matching values

前端 未结 4 882
我在风中等你
我在风中等你 2020-12-14 03:32

I have two arrays that I need to check against each other and if they have reached a point where both items in each array are actually the same as one another, then append s

4条回答
  •  天涯浪人
    2020-12-14 03:52

    Hi using lodash or underscore you can easily intersection two array.

    _.intersection([2, 1], [2, 3]);

    Result is [2].

    Lodash document: https://lodash.com/docs/4.17.2#intersection

提交回复
热议问题