0

I have an array of urls links:

const urlLinks = [`http://1`,
`http:/2`,
`http://3`,
`http://4`,
`http://5`
]

How would I write an if statement, that would be executed, when at least one of the links in the array is present?

if (URL === urlLinks) {
Barmar
  • 669,327
  • 51
  • 454
  • 560
Menor
  • 292
  • 2
  • 12
  • [`Array.prototype.includes`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes) – Barmar Apr 07 '20 at 22:13

1 Answers1

0

Like this:

if (urlLinks.includes(URL)) { ... }

This will return true if URL is in the urlLinks array.

Array.prototype.includes

Barry Michael Doyle
  • 7,792
  • 23
  • 75
  • 128