I’m currently creating a macro calculator but I’m getting an error with the actual calculation function. The error I’m getting is ‘Missing initializer in const declaration’.
const [weight,setWeight] = useState("");
const [height, setHeight] = useState("");
const [age, setAge] = useState("");
const [activityLevel, setActivityLevel] = useState("");
const handleSubmit = (e) => {
e.preventDefault();
}
const calculateMacros(weight,height,age,activityLevel) => {
const BMR = 10 * weight + 6.25 * height - 5 * age;
let TDEE = 0;
switch(activityLevel) {
case 'sedentary':
TDEE = BMR * 1
}
}
>Solution :
Umm…
I think this part is incorrect.
const calculateMacros(weight,height,age,activityLevel) => {...}
This must be like below code:
const calculateMacros = (weight,height,age,activityLevel) => {...}