🇺🇸 U.S. Fitness & Nutrition Calculator
Track calories, protein, BMI, and macros – optimized for Americans
Calculate Your Daily Needs
Latest Articles
- Loading latest articles…
if (!age || age < 1 || age > 120) { alert("Please enter a valid age (1–120)."); return; } if (!weight || weight < 10 || weight > 300) { alert("Please enter a valid weight (10–300 kg)."); return; } if (!height || height < 50 || height > 250) { alert("Please enter a valid height (50–250 cm)."); return; }
let bmr; if (gender === "male") { bmr = 10 * weight + 6.25 * height - 5 * age + 5; } else { bmr = 10 * weight + 6.25 * height - 5 * age - 161; }
let calories = bmr * activity;
if (goal === "loss") { calories -= 500; } else if (goal === "gain") { calories += 300; }
// Macronutrients (protein/fat/carbs) let proteinFactor = 1.6; // default maintenance if (goal === "loss") proteinFactor = 1.8; if (goal === "gain") proteinFactor = 2.0;
const proteinGrams = proteinFactor * weight; const proteinCals = proteinGrams * 4; const fatCals = calories * 0.25; const fatGrams = fatCals / 9; const carbCals = calories - proteinCals - fatCals; const carbGrams = carbCals / 4;
// BMI calculation const heightM = height / 100; const bmi = weight / (heightM * heightM); const bmiStatus = bmiCategory(bmi);
const resultDiv = document.getElementById("result"); resultDiv.style.display = "block"; resultDiv.innerHTML = ` 🔥 Daily Caloric Needs: ${Math.round(calories)} kcal
🍗 Protein: ${proteinGrams.toFixed(1)} g
🥑 Fats: ${fatGrams.toFixed(1)} g
🍚 Carbs: ${carbGrams.toFixed(1)} g
📏 BMI: ${bmi.toFixed(1)} (${bmiStatus}) `; }
function bmiCategory(bmi) { if (bmi < 18.5) return "Underweight"; else if (bmi < 24.9) return "Normal weight"; else if (bmi < 29.9) return "Overweight"; else return "Obese"; } // Fetch latest 5 posts from WordPress REST API async function loadLatestArticles() { const list = document.getElementById('articles-list'); try { // Change this URL to your actual WordPress site URL if different! const response = await fetch('https://fitnesstoday.us/wp-json/wp/v2/posts?per_page=5&_fields=title,link,date'); if (!response.ok) throw new Error("Network response was not ok"); const posts = await response.json(); if(posts.length === 0) { list.innerHTML = '
'; return; }
list.innerHTML = ''; // Clear loading
posts.forEach(post => { const title = post.title.rendered || 'Untitled'; const date = new Date(post.date).toLocaleDateString('en-US', { year:'numeric', month:'short', day:'numeric' }); const li = document.createElement('li'); li.innerHTML = `${title}Published: ${date}`; list.appendChild(li); }); } catch (error) { list.innerHTML = `
`; } }
loadLatestArticles();