Learn-form-validation-by-building-a-calorie-counter step 77

Tell us what’s happening:

Describe your issue in detail here.
i wrote the code as i believe i should but it keep on saying
You should have a ternary operator that checks if remainingCalories is less 0 .

Your code so far

const surplusOrDeficit = remainingCalories >= 0 ? "Surplus" : "Deficit"; 

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

use ’ instead of " . that works for me.

i tried it still did not work

[ Step 77

You need to know if the user is in a caloric surplus or deficit. A caloric surplus is when you consume more calories than you burn, and a caloric deficit is when you burn more calories than you consume. Burning as many calories as you consume is called maintenance, and can be thought of as a surplus or deficit of 0, depending on your goals.

Declare a surplusOrDeficit variable. Then use a ternary operator to set surplusOrDeficit to the string Surplus or Deficit depending on whether remainingCalories is less than 0. If it is less than 0, then surplusOrDeficit should be Surplus. Otherwise, it should be Deficit.
i have tried to write the code but it keeps on saying
You should have a ternary operator that checks if remainingCalories is less `0 .
here is my code
const surplusOrDeficit = remainingCalories >= 0 ? “Surplus” : “Deficit”;

Note that the instructions say less than

I updated your post to include the correct challenge link and code.

As was mentioned earlier, this is incorrect

this is checking for if remainingCalories is greater than or equal to 0.
But that is not what the directions say.

Please re read the directions here to fix to the issue and pass the test

If it is less than 0, then `surplusOrDeficit` should be Surplus. Otherwise, it should be Deficit.

where is the updated post ? i did the same code but it keeps on saying error

I updated the OP’s original post to include the challenge link and wrap their code inside a code block so we could read it.

I didn’t alter their answer.
I just wrapped it in code blocks so we could read it.

If you need help with a challenge, please create a new post and we can help you there :+1:

If someone will look for an answer:
The code above won’t work because you should check if it is less than 0, not less and equal 0. So just make sure that you use “<” & “>” properly. :wink:

hey @dave_s

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

1 Like

Thank you for pointing it out! I just adjusted my comment also so it looks little better now!
This is actually a valid point, to not give the “food” but the tools to prepare it. :smiley: