Learn-form-validation-by-building-a-calorie-counter - Step 44

**I really dont get, what the problem is in my code, this is the error Message i get: **

Your HTMLString variable should start with a new line.

this is my code:

const HTMLString = `\n<label>Entry ${entryNumber} Name</label>`;
2 Likes

Please don’t delete the link to the step. Can you please put it back? Thanks

do you mean this link: https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures-v8/learn-form-validation-by-building-a-calorie-counter/step-44

Yep, thanks.

They are looking for a literal linebreak, not the newline character.

2 Likes

ok now i get it,
i got the solution now,
thanks

1 Like

This is not a line break at all it seems to be a needless space we are adding for absolutely no reason or explanation as to why. Does adding a new line in your code editor during a literal statement do anything special?

You should get this part reviewed as currently I am just adding a random space for absolutely no reason in my mind. Is it best practice to format this way?

This entire thing would have been made more clear in the tutorial if it simply said "In your code editor start the literal statement on a new line.

Instead it says “Start your HTMLString with a new line” ← this means that in your literal statement you want to start it with \n or <br> both are for new lines.

These instructions need to be properly worded.

Also explanation as to why we are adding what seems like an absolutely useless space within the editor would be nice.

const HTMLString = `
New line example `;

^ Why would you do this? Seems absolutely pointless to me and the instructions seems poorly written.

Also saying a Literal linebreak when we are learning literal statements T_T I went looking for a literal linebreak thinking that literal statements have their own linebreak command.

Now if this is best practice for formatting if that was mentioned in the instructions it would start to make more sense to anyone reading it as to what they are expected to do.

Sorry for the little rant just that was about 30 minutes of wasted time because something was poorly worded.

12 Likes

It is a ‘line break’. I agree that the wording should be improved, but it is literally a line break.

2 Likes

does it act as a line break when display any code?

To me that new line in the editor is pointless and changes nothing. How does it affect the output?

If it is picked up as a new line when compiling this makes sense but should be explained.

The line break is in the string that’s being used, so it changes the displayed text.

So essentially hitting enter and starting the literal statement on a new line will act the same as using \n or <br> when compiled.

There is no ‘compiled’ here. HTML isnt compiled

So it does nothing and does not start the statement on a new line.

Javascript is not compiled got you. Sorry this is like pulling teeth.

What is the purpose of adding a space in the code editor in terms of the final output.

It doesn’t 'do nothing '. That line break is in the string. Try console logging it.

Thank you, I just wanted to know if this is best practice in terms of how to format your code or not. It has no actual impact on the code what so ever.

This is still false. You are changing the contents of the string

Does it make the string start on a new line? Elaborate?

the first character of the string will be a new line

There is a line break in the string. It’s a different string than one that doesn’t have a line break in it.

Thank you so it acts the same as a new line character like using \n or <br> in html.

no, because we are writing the html itself, not the content of the page. It acts like pressing enter while writing code.