I tried this however it didn't work.
const tlds = [".com", ".net", ".it", ".edu", ".gov"]
ent/*ent is an existing variable in my code*/.endsWith(tlds)
Do I have to make it that it checks through each item in the array?
Yes, you have to make it so that it checks through each item in the array. You could make a for-loop to check all items in the array. Here's my code.
const tlds = [".com", ".net", ".it", ".edu", ".gov"]
function endsWith(string, end) {
for (let i = 0; i < tlds.length; i++) {
if (string.endsWith(end[i]) === true) return true
}
return false
}
endsWith(ent, tlds)
Hope this helps(;