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
  • 741,623
  • 53
  • 500
  • 612
Menor
  • 302
  • 2
  • 14
  • [`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
  • 9,333
  • 30
  • 83
  • 143