**Introduction**

Calculating time spent on various activities is a common need in many aspects of life, from work tasks to personal projects. To simplify this process, a Time Spent Calculator can be a handy tool. In this article, we’ll provide a simple and efficient HTML and JavaScript code for creating a Time Spent Calculator.

**How to Use**

- Input the time spent on each activity in hours.
- Click the “Calculate” button to get the total time spent.

**Formula**

The formula for calculating the total time spent is straightforward:

$Total Time Spent=Time Spent on Activity 1+Time Spent on Activity 2+…+Time Spent on Activity n$

**Example**

Consider the following scenario:

- Activity 1: 2 hours
- Activity 2: 1.5 hours
- Activity 3: 3.5 hours

Using the formula, the total time spent is $2+1.5+3.5=7$ hours.

**FAQs**

**Q: Can I add more activities to calculate time spent?**

**A:** Yes, you can. Simply add more input fields following the provided structure in the HTML code.

**Q: What if I input non-numeric values?**

**A:** The calculator will treat non-numeric values as zero.

**Conclusion**

Creating a Time Spent Calculator using HTML and JavaScript can significantly ease the process of calculating total time spent on various activities. The provided code is customizable for different needs, allowing users to input the time spent on different tasks and obtain accurate results.