Write a useful tool in jawsript
user
sure! below is a simple javascript tool to calculate the bmi (body mass index) from a person's weight (in kg) and height (in meters). you can paste it in an html file and see it in action.

```html
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>bmi calculator</title>
</head>
<body>
  <h1>bmi calculator</h1>
  <form id="bmiform">
    <label for="weight">weight (kg):</label>
    <input type="number" id="weight" required>
    <br><br>
    <label for="height">height (m):</label>
    <input type="number" id="height" step="0.01" required>
    <br><br>
    <button type="submit">calculate bmi</button>
  </form>
  <br>
  <div id="result"></div>

  <script>
    document.getelementbyid('bmiform').addeventlistener('submit', function (event) {
      event.preventdefault();
      
      const weight = parsefloat(document.getelementbyid('weight').value);
      const height = parsefloat(document.getelementbyid('height').value);

      const bmi = calculatebmi(weight, height);
      
      document.getelementbyid('result').innertext = 'your bmi is: ' + bmi.tofixed(1);
    });

    function calculatebmi(weight, height) {
      return weight / (height * height);
    }
  </script>
</body>
</html>
```

this simple bmi calculator takes the weight and height inputs from the user and calculates the bmi value on form submission. the result is then displayed below the form.
assistant
Sure! Below is a simple JavaScript tool to calculate the BMI (Body Mass Index) from a person's weight (in kg) and height (in meters). You can paste it in an HTML file and see it in action.

```html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>BMI Calculator</title>
</head>
<body>
  <h1>BMI Calculator</h1>
  <form id="bmiForm">
    <label for="weight">Weight (kg):</label>
    <input type="number" id="weight" required>
    <br><br>
    <label for="height">Height (m):</label>
    <input type="number" id="height" step="0.01" required>
    <br><br>
    <button type="submit">Calculate BMI</button>
  </form>
  <br>
  <div id="result"></div>

  <script>
    document.getElementById('bmiForm').addEventListener('submit', function (event) {
      event.preventDefault();
      
      const weight = parseFloat(document.getElementById('weight').value);
      const height = parseFloat(document.getElementById('height').value);

      const bmi = calculateBMI(weight, height);
      
      document.getElementById('result').innerText = 'Your BMI is: ' + bmi.toFixed(1);
    });

    function calculateBMI(weight, height) {
      return weight / (height * height);
    }
  </script>
</body>
</html>
```

This simple BMI calculator takes the weight and height inputs from the user and calculates the BMI value on form submission. The result is then displayed below the form.
assistant