Intenté esto, sin embargo, no funcionó.
const tlds = [".com", ".net", ".it", ".edu", ".gov"] ent/*ent is an existing variable in my code*/.endsWith(tlds)¿Tengo que hacer que verifique cada elemento de la matriz?
Sí, debe hacerlo de modo que verifique cada elemento de la matriz. Puede hacer un ciclo for para verificar todos los elementos en la matriz. Aquí está mi código.
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)Espero que esto ayude(;