Is it necessary to leave line after if statement like I have done in description ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Is it necessary to leave line after if statement like I have done in description ?

if (var 1 > var 2) { document.write("Ok"); } After {, I have lft line. If we don't have to do why in most learning platforms we see so ?

3rd Jun 2021, 3:36 AM
Harsh
Harsh - avatar
3 Answers
+ 4
Compiler/interpreter doesn't care how many space or line break was inserted, as long as the code was syntactically correct. Coders have different preferences on how the braces are placed. It doesn't matter much, nor it is necessary to adopt a certain brace placement (styling). What matters more about this, is how readable the code is for the public (when the code is public), and the coder him/herself in particular.
3rd Jun 2021, 3:51 AM
Ipang
+ 2
Harsh Kishore Not necessary. If you see jQuery library, you will see then is even no single break after each statement. That's what we say minified version.
3rd Jun 2021, 4:26 AM
A͢J
A͢J - avatar
+ 1
Thanx everyone
5th Jun 2021, 3:26 AM
Harsh
Harsh - avatar