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

89
Views
Calculadora Javascript cómo permitir múltiples puntos

Básicamente, este proyecto está casi terminado. Pero cuando lo estaba 'probando', descubrí que no puedo crear varios puntos. Sé por qué no puedo hacer eso:

 // if there is any dot, and user want to add another dot, then return if(containDot && operand == '.') return;

Entonces, el problema es que no tengo otra idea, ¿cómo puedo bloquear la adición de múltiples puntos en UN número y al mismo tiempo permitir agregarlo a otros números con la idea de realizar operaciones con eval();

Aquí hay un enlace al código: https://codepen.io/Igor34/pen/LYyoZMR

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

0

Modifiqué su código para dividir el texto en cada número y buscar un punto solo en el último número.

 const currentOperator = this.currentScreen.textContent.split(/[-+\\/\\*]/).pop(); // if there is any dot, and user want to add another dot, then return if (currentOperator.includes(".") && operand === ".") return // LINE BELOW REMOVED // if(containDot && operand == '.') return;

Ver https://codepen.io/jmendes/pen/XWRwjJm

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!