Learn Form Validation by Building a Calorie Counter - Step 77

Tell us what’s happening:

I know this is correct and it keeps stating that it is wrong

Your code so far

const calorieCounter = document.getElementById('calorie-counter');
const budgetNumberInput = document.getElementById('budget');
const entryDropdown = document.getElementById('entry-dropdown');
const addEntryButton = document.getElementById('add-entry');
const clearButton = document.getElementById('clear');
const output = document.getElementById('output');
let isError = false;

function cleanInputString(str) {
  const regex = /[+-\s]/g;
  return str.replace(regex, '');

function isInvalidInput(str) {
  const regex = /\d+e\d+/i;
  return str.match(regex);

function addEntry() {
  const targetInputContainer = document.querySelector(`#${entryDropdown.value} .input-container`);
  const entryNumber = targetInputContainer.querySelectorAll('input[type="text"]').length + 1;
  const HTMLString = `
  <label for="${entryDropdown.value}-${entryNumber}-name">Entry ${entryNumber} Name</label>
  <input type="text" id="${entryDropdown.value}-${entryNumber}-name" placeholder="Name" />
  <label for="${entryDropdown.value}-${entryNumber}-calories">Entry ${entryNumber} Calories</label>
  targetInputContainer.insertAdjacentHTML('beforeend', HTMLString);
function calculateCalories(e) {
  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([budgetNumberInput]);

  if (isError) {

  const consumedCalories = breakfastCalories + lunchCalories + dinnerCalories + snacksCalories;
  const remainingCalories = budgetCalories - consumedCalories + exerciseCalories;
  const surplusOrDeficit = remainingCalories > =0 ? "Surplus" : "Deficit";

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.15

Challenge Information:

Learn Form Validation by Building a Calorie Counter - Step 77

Hi there and welcome to our community!

You have a syntax error in this line, as there should not be a space between > and =.
It’s also an incorrect comparison as the instructions ask you to check if remainingCalories is less than 0, not greater than or equal to 0.

Sorry, still confused. I moved to reflect
const surplusOrDeficit = remainingCalories >= 0 ? “Surplus” : “Deficit”;

It still doesn’t pass.

It is the wrong comparison:

I guess I don’t know that that means. I even watched a YouTube video where they ran the exact code I did and it passed. Sorry for sounding stupid I am very confused

I am sorry, I clearly must be dumb. I figured it out. Thank you.

No, you’re not dumb. We all struggle to understand various things.
Here’s a simple example of different comparison operators:

// a is greater than 0
a > 0

// a is smaller than 0
a < 0

// a is greater than or equal to 0
a >= 0

// a is smaller than or equal to 0
a <= 0

// a is equal to 0
a == 0

// a is not equal to 0
a != 0

I hope that helps!