Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #38732

Re: Find part match in array

Newsgroups comp.lang.javascript
Date 2020-08-17 05:01 -0700
References <9rCdnYySpppZSKTCnZ2dnUU7-N3NnZ2d@westnet.com.au>
Message-ID <b12e73f4-32ba-4ecc-acdc-e11a2f924f80o@googlegroups.com> (permalink)
Subject Re: Find part match in array
From Julio Di Egidio <julio@diegidio.name>

Show all headers | View raw


On Monday, 17 August 2020 02:56:45 UTC+2, Andrew Poulos  wrote:
> If I have this
> 
> let arr1 = ["Today", "Freddy", "was", "here"];
> 
> what's a straightforward way to find that there's a match with this array
>    arr2 = ["Fred", "Yesterday"];
> (the first element "matches" the second element in arr1 ie 'Fred' is 
> within 'Freddy')?

"Matches/is within" as in *contains*?  Otherwise what?

One of the two arrays is fixed (constant) and you match the other
against it?  Or, both arrays are dynamic and you need to cross-match
them?

> const matched = arr1.some(a => arr2.includes(a));

Besides asking sloppy questions, do you use const vs let
(vs var, and functions vs lambdas) just randomly?  Or is
it on purpose to make the code (even more) unreadable?

Julio

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Find part match in array Andrew Poulos <ap_prog@hotmail.com> - 2020-08-17 10:56 +1000
  Re: Find part match in array Andrew Poulos <ap_prog@hotmail.com> - 2020-08-17 13:06 +1000
  Re: Find part match in array "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2020-08-16 20:54 -0700
  Re: Find part match in array JJ <jj4public@vfemail.net> - 2020-08-17 16:36 +0700
  Re: Find part match in array Julio Di Egidio <julio@diegidio.name> - 2020-08-17 05:01 -0700
  Re: Find part match in array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-17 19:36 +0200
    Re: Find part match in array Andrew Poulos <ap_prog@hotmail.com> - 2020-08-18 09:02 +1000
      Re: Find part match in array Andrew Poulos <ap_prog@hotmail.com> - 2020-08-18 13:09 +1000
      Re: Find part match in array "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-18 11:28 +0200
        Re: Find part match in array "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2020-08-18 12:59 +0200
      Re: Find part match in array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2020-08-18 21:59 +0200

csiph-web