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

166
Views
¿Cómo agregar una tasa de impuestos a mi costo en javascript?

No estoy seguro de cómo agregar impuestos (7%) a mi costo ($6) en Javascript. ¿Alguien puede ayudarme?

html

 <div class="item main"> <h1>Enter a Title</h1> <p>Please enter a title to calculate how much it will cost<br> <input id = "titleBox" type = "text"> <button onclick="calculateCost()">Enter</button> </p> <p id= "output">Result</p> </div>

JavaScript

 var titleName; var cost = 6; function calculateCost() { titleName = document.getElementById("titleBox").value; var titleLetters; titleLetters = titleName.length; var spaceCount = (titleName.split(" ").length - 1); document.getElementById("output").innerHTML = "$" + (titleLetters - spaceCount) * cost; /* "Red Car" "Red" "Car" */ }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Es bastante básico (solo matemática simple), aquí está la implementación:

 var titleName; var cost = 6; const tax = 7/100; // Added the tax function calculateCost() { titleName = document.getElementById("titleBox").value; var titleLetters; titleLetters = titleName.length; var spaceCount = (titleName.split(" ").length - 1); document.getElementById("output").innerHTML = "$" + ((titleLetters - spaceCount) * cost*(1+tax)); // Since we have to add tax we have to use 1+tax /* "Red Car" "Red" "Car" */ }

Nota: desplácese hacia la derecha para ver la fórmula actualizada desde que salió del cuadro de código de desbordamiento de pila

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!