Learn Form Validation by Building a Calorie Counter - Step 73

Tell us what’s happening:

Ok, this is the request:
Declare a budgetCalories variable and set it to the result of calling getCaloriesFromInputs – pass an array containing your budgetNumberInput as the argument.

And I get this hint for the code below:
You should call getCaloriesFromInputs with [budgetNumberInput] as the argument

Your code so far

function calculateCalories(e) {
e.preventDefault();
isError = false;

const breakfastNumberInputs = document.querySelectorAll(‘#breakfast input[type=number]’);
const lunchNumberInputs = document.querySelectorAll(‘#lunch input[type=number]’);
const dinnerNumberInputs = document.querySelectorAll(‘#dinner input[type=number]’);
const snacksNumberInputs = document.querySelectorAll(‘#snacks input[type=number]’);
const exerciseNumberInputs = document.querySelectorAll(‘#exercise input[type=number]’);

const breakfastCalories = getCaloriesFromInputs(breakfastNumberInputs);
const lunchCalories = getCaloriesFromInputs(lunchNumberInputs);
const dinnerCalories = getCaloriesFromInputs(dinnerNumberInputs);
const snacksCalories = getCaloriesFromInputs(snacksNumberInputs);
const exerciseCalories = getCaloriesFromInputs(exerciseNumberInputs);
const budgetCalories = getCaloriesFromInputs(budgetNumberInputs);
const budgetCalories = getCaloriesFromInputs([budgetNumberInputs]);

}

WARNING

The challenge seed code and/or your solution exceeded the maximum length we can port over from the challenge.

You will need to take an additional step here so the code you wrote presents in an easy to read format.

Please copy/paste all the editor code showing in the challenge from where you just linked.

Replace these two sentences with your copied code.
Please leave the ``` line above and the ``` line below,
because they allow your code to properly format in the post.

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 73

first delete the copy of the variable you made
then remove the last s from budgetNumberInput and it will work, like this:

const budgetCalories = getCaloriesFromInputs([budgetNumberInput]);

happy coding.

Hi my friend
remenber he told us A NodeList is an array-like and budgetNumberInput variable. However, you used getElementById , which returns an Element , not a NodeList .whereby we have to send an array with the element budgetNumberInput inside [budgetNumberInput]

const budgetCalories = getCaloriesFromInputs([budgetNumberInput]);
this worked for me

greetings

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.