For curly braces {} after if / other

When we have only one command in the body of the if construction, we can skip the curly brackets, indicating the conditional operator body. When we want to execute block of code (group of commands), curly brackets are required. In case we drop them, only the first line after if clause will be executed.

It's a good practice to always put curly braces, because it makes our code more readable and clean.

Here is an example where dropping curly braces leads to confusion:

Execute the above code will output the following console result:

With curly braces:

The following output will be printed on the console:

results matching ""

    No results matching ""