main.js 412 B

123456789101112131415
  1. const input_number = document.querySelector("#input-number");
  2. const output = document.querySelector("#output");
  3. const btn_submit = document.querySelector("#btn-submit");
  4. function miles_to_km(miles)
  5. {
  6. return miles * 1.609344;
  7. }
  8. btn_submit.addEventListener("click", (event) => {
  9. const number = input_number.value;
  10. const result = miles_to_km(number);
  11. output.textContent = `Result: ${result}`;
  12. });