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

191
Views
¿Cómo puedo verificar si el primer índice en esta cadena es = '1' y luego eliminarlo?

Estoy creando un formateador de números de teléfono y todo funciona excepto esta parte. El error con el que me encuentro es este: "Error de tipo: no se puede leer la propiedad 'indexOf' de undefined". Intenté usar .includes('1',0) en su lugar, pero tampoco funcionó.

 // If cleanNumber has a country code(1), remove it if((cleanNumber.indexOf("1")) = 0){ cleanNumber = cleanNumber.substring(1); //removes first character = "1" activeSheet.getRange(i,3).setValue(cleanNumber); Logger.log("Country code removed: " + cleanNumber); }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

= es un operador de asignación.

== es un operador de comparación.

Utilice == en su lugar.

 if ((cleanNumber.indexOf("1")) == 0) { cleanNumber = cleanNumber.substring(1); //removes first character = "1" activeSheet.getRange(i, 3).setValue(cleanNumber); Logger.log("Country code removed: " + cleanNumber); }
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!