function BMICalculator() { const [weight, setWeight] = useState(''); const [height, setHeight] = useState(''); const [bmi, setBmi] = useState(null); const calculateBMI = () => { const h = parseFloat(height) / 100; const result = parseFloat(weight) / (h * h); setBmi(result.toFixed(2)); }; const getCategory = () => { if (!bmi) return ''; if (bmi < 18.5) return { text: 'Underweight', color: 'var(--warning)' }; if (bmi < 25) return { text: 'Normal', color: 'var(--success)' }; if (bmi < 30) return { text: 'Overweight', color: 'var(--warning)' }; return { text: 'Obese', color: 'var(--danger)' }; }; const category = getCategory(); return (

⚖️ BMI Calculator

setWeight(e.target.value)} placeholder="70" />
setHeight(e.target.value)} placeholder="170" />
{bmi && (
BMI: {bmi}
Category: {category.text}
)}
); } // Export to global registry window.BMICalculator = BMICalculator;