Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Getting error in function with calculation function

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 :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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) => {...}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading