// Global Variables
let totalCalories = 0;
let totalWater = 0;
let totalSteps = 0;
let totalSleep = 0;
let todoList = [];
// 1. User Registration (LocalStorage for persistence)
function registerUser() {
const username = [Link]("username").value;
const password = [Link]("password").value;
if (username && password) {
[Link]('username', username);
[Link]('password', password);
alert("User Registered!");
} else {
alert("Please fill in all fields.");
// 2. BMI Calculator
function calculateBMI() {
const height = [Link]("height").value;
const weight = [Link]("weight").value;
if (height && weight) {
const heightInMeters = height / 100;
const bmi = weight / (heightInMeters * heightInMeters);
[Link]("bmi-result").textContent = `Your BMI: ${[Link](2)}`;
} else {
alert("Please enter both height and weight.");
// 3. Calorie Tracker (Food logging)
function addFood() {
const foodName = [Link]("food-name").value;
const calories = prompt(`Enter calories for ${foodName}:`);
if (calories) {
totalCalories += parseInt(calories);
[Link]("calorie-consumed").textContent = totalCalories;
// 4. Step Counter (Geolocation API)
function getGeolocation() {
if ([Link]) {
[Link](function(position) {
// Using dummy data here since real-time steps would require a pedometer API or device
totalSteps += 1000; // For example
[Link]("steps-count").textContent = totalSteps;
});
} else {
alert("Geolocation is not supported by this browser.");
// 5. Water Tracker
function addWater() {
const waterIntake = parseInt([Link]("water-intake").value);
if (waterIntake) {
totalWater += waterIntake;
[Link]("water-consumed").textContent = totalWater;
// 6. Sleep Tracker
function saveSleep() {
const sleepHours = [Link]("sleep-hours").value;
if (sleepHours) {
totalSleep += parseInt(sleepHours);
[Link]("sleep-result").textContent = `You have slept for ${totalSleep} hours
today.`;
// 7. To-Do List
function addToDo() {
const todoItem = [Link]("todo-item").value;
if (todoItem) {
[Link](todoItem);
updateTodoList();
function updateTodoList() {
const todoListElement = [Link]("todo-list");
[Link] = ''; // Clear the current list
[Link]((item, index) => {
const li = [Link]('li');
[Link] = item;
[Link](li);
});
// Get DOM elements
const workoutForm = [Link]('workout-form');
const exerciseInput = [Link]('exercise');
const setsInput = [Link]('sets');
const repsInput = [Link]('reps');
const weightInput = [Link]('weight');
const restInput = [Link]('rest');
const workoutList = [Link]('workout-list');
// Event listener for form submission
[Link]('submit', function (event) {
[Link]();
// Get form values
const exercise = [Link]();
const sets = [Link]();
const reps = [Link]();
const weight = [Link]();
const rest = [Link]();
// Validate form inputs
if (exercise && sets && reps) {
// Create a new workout item
const workoutItem = [Link]('li');
// Format workout details
let workoutDetails = `${exercise} | ${sets} sets x ${reps} reps`;
if (weight) {
workoutDetails += ` | Weight: ${weight} kg/lbs`;
if (rest) {
workoutDetails += ` | Rest: ${rest} seconds`;
[Link] = `
<span>${workoutDetails}</span>
<button class="delete">Delete</button>
`;
// Delete functionality
[Link]('.delete').addEventListener('click', function () {
[Link]();
});
// Append to workout list
[Link](workoutItem);
// Clear form fields
[Link] = '';
[Link] = '';
[Link] = '';
[Link] = '';
[Link] = '';
} else {
alert("Please fill out all required fields.");
});