Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

270
Views
¿Cómo usar el método JS Endswith() para verificar si una variable de cadena termina con algún elemento de una matriz?

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

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(;

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!