Just make a little helper function that does what you said, loops through the array and checks each value. An efficient way to do that is with Array.some, as it will return true as soon as it finds a truthy match.

let validSLDs = ['hulu','netflix']

let string1 = 'www.hulu.com/watch/...';
let string2 = 'http://www.netflix.com/watch/...';
let string3 = 'imdb.com/title/....'

const isURLOK = (testString) => validSLDs.some(v => testString.indexOf(v) > -1);

console.log(isURLOK(string1));
console.log(isURLOK(string2));
console.log(isURLOK(string3));

Answer from James on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Array › indexOf
Array.prototype.indexOf() - JavaScript | MDN
const beasts = ["ant", "bison", "camel", "duck", "bison"]; console.log(beasts.indexOf("bison")); // Expected output: 1 // Start from index 2 console.log(beasts.indexOf("bison", 2)); // Expected output: 4 console.log(beasts.indexOf("giraffe")); // Expected output: -1 ... Element to locate in the array. ... Zero-based index at which to start searching, converted to an integer. Negative index counts back from the end of the array — if -array.length <= fromIndex < 0, fromIndex + array.length is used.
🌐
DigitalOcean
digitalocean.com › community › tutorials › js-indexof
Exploring the indexOf Method for Strings and Arrays in JavaScript | DigitalOcean
December 17, 2019 - Lookout here comes 🐊!" const spencersIndex = whereIsSpencer.indexOf('Spencer'); // spencersIndex === 23 // to find find the second occurence of 'Spencer', // we need to add one to the position of spencer #1 const secondSpencerIndex = whereIsSpencer.indexOf('Spencer', spencersIndex + 1); // secondSpencerIndex === 46 const alligatorIndex = whereIsSpencer.indexOf('🐊'); // alligatorIndex === 91 // Be careful the search is case sensitive! const lowerCaseSpencer = whereIsSpencer.indexOf('spencer'); // lowerCaseSpencer === -1 · Now we can create the same indicesOf function for Array.prototype.string.
🌐
W3Schools
w3schools.com › jsref › jsref_indexof_array.asp
JavaScript Array indexOf() Method
The indexOf() method starts at a specified index and searches from left to right (from the given start postion to the end of the array).
🌐
Tabnine
tabnine.com › home › how to use the indexof method in javascript
How to Use the indexOf method in JavaScript - Tabnine
July 25, 2024 - As array indices begin at zero, the value 0 is returned. The below example demonstrates how to use indexOf() with a string: const str = 'How much wood would a woodchuck chuck'; console.log(str.indexOf('wood')); // Expected output: 9 · The code sample above searches the sentence stored in const str for the term wood. The first appearance of this term begins at index 9, despite there being two occurrences of the term “wood” in the string, and thus the value 9 is returned.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › indexOf
String.prototype.indexOf() - JavaScript | MDN
The method returns the index of the first occurrence of the specified substring at a position greater than or equal to position, which defaults to 0. If position is greater than the length of the calling string, the method doesn't search the calling string at all.
🌐
Programiz
programiz.com › javascript › library › array › indexof
JavaScript Array indexOf()
Note: indexOf() compares searchElement to elements of the Array using strict equality (similar to triple-equals operator or ===). var priceList = [10, 8, 2, 31, 10, 1, 65]; // indexOf() returns the first occurance · var index1 = priceList.indexOf(31); console.log(index1); // 3
🌐
JavaScript Tutorial
javascripttutorial.net › home › javascript array methods › array.prototype.indexof()
JavaScript Array indexOf() Method
November 6, 2024 - Summary: in this tutorial, you will learn how to use JavaScript Array indexOf() method to find the index of the first matching element in an array
Find elsewhere
🌐
Mimo
mimo.org › glossary › javascript › array-indexof-method
JavaScript Array indexOf() method: Syntax, Usage, and Examples
The indexOf() method lets you search an array for a specific value and returns its first index. If the value isn’t found, it returns -1. The JavaScript array indexOf method is a quick and reliable way to determine the position of an element in an array, especially when working with primitive ...
🌐
W3Schools
w3schools.com › jsref › jsref_indexof.asp
JavaScript String indexOf() Method
The indexOf() method returns the position of the first occurrence of a value in a string.
🌐
Appdividend
appdividend.com › 2018 › 12 › 19 › javascript-array-indexof-example-tutorial
JavaScript Array indexOf() Method
September 30, 2025 - The “diwali” exists at positions 1 and 3, but it only returns the index of the first element, and hence it returns 1 in the output. If you want to skip the earlier matches, you can use the fromIndex argument. For example, if you wish to get the second occurrence’s index, you can pass the fromIndex argument. const festivals = ['holi', 'diwali', 'christmas', 'diwali']; console.log(festivals.indexOf('diwali', 2)); // Output: 3 · If fromIndex is negative, it is interpreted as: startIndex = array.length + fromIndex
🌐
Medium
medium.com › front-end-weekly › the-difference-between-indexof-and-findindex-in-javascript-a2035639dce5
The Difference Between indexOf and findIndex in JavaScript | by Sumit kumar Singh | Frontend Weekly | Medium
June 8, 2023 - For arrays: array.indexOf(searchElement, fromIndex) For strings: string.indexOf(searchValue, fromIndex) ... fromIndex (optional): The index to start searching from. If not specified, the search starts from index 0. The indexOf method returns ...
🌐
MSR
rajamsr.com › home › javascript indexof(): the best way to search arrays and strings
JavaScript IndexOf(): The Best Way to Search Arrays and Strings | MSR - Web Dev Simplified
March 12, 2024 - Are looking to check whether a value exists in a string or array? you can use the JavaScript indexOf() method. The index of the first occurrence will be returned for the specified value in a string or array.
🌐
ZetCode
zetcode.com › js-array › indexof
JavaScript indexOf - finding elements in JS
The loop starts searching from the position after the last found index. Each found position is added to the indices array. This technique works for both arrays and strings. ... In this article we have demonstrated how to use the indexOf() method to find elements in JavaScript arrays and strings.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-array-indexof-method
JavaScript Array indexOf() Method | GeeksforGeeks
September 27, 2024 - This code demonstrates the use of the indexOf() method to find the index of a specific element (2) in an array (A). It returns the index of the first occurrence of the element in the array (1 in this case).
🌐
TutorialsPoint
tutorialspoint.com › home › javascript › javascript array indexof method
JavaScript Array indexOf Method Explained
September 1, 2008 - The JavaScript Array indexOf() method is used to return the first occurrence index of a specified element within an array (if it is present at least once).
🌐
CoreUI
coreui.io › answers › how-to-find-the-index-of-an-element-in-an-array-in-javascript
How to find the index of an element in an array in JavaScript · CoreUI
September 19, 2025 - The indexOf() method searches the array from the beginning and returns the index of the first occurrence of the specified element, or -1 if the element is not found. In this example, fruits.indexOf('banana') returns 1 because ‘banana’ first ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › TypedArray › indexOf
TypedArray.prototype.indexOf() - JavaScript | MDN
The indexOf() method of TypedArray instances returns the first index at which a given element can be found in the typed array, or -1 if it is not present.
🌐
Codedamn
codedamn.com › news › javascript
indexOf() String Method in JavaScript
June 6, 2023 - JavaScript is widely used for web development."; const searchValue = "JavaScript"; let count = 0; let index = 0; while ((index = str.indexOf(searchValue, index)) !== -1) { count++; index += searchValue.length; } console.log(`${searchValue} appears ${count} times in the string.`); // Output: JavaScript appears 2 times in the string. In this example, we use a while loop to search for the specified value repeatedly until no more occurrences are found. We update the index variable by adding the length of the search value to ensure that the loop starts searching from the next character after the current occurrence. Q: Can we use the indexOf() method with arrays in JavaScript?