When to use semicolons and brackets
javascript
Solution
Semicolons should be used to terminate statements. Brackets should be used to group more than one statements in a code block, for example when writing `if` conditions, loops (`for`, `while`) or functions. Brackets are also used when creating objects.
Example:
var foo = 'bar';
if (foo == 'bar') {
for (var i = 0; i < 5; i++) {
alert('Hello ' + i);
}
}
Problem
I am still having a hard time figuring out when to use semicolons ; and brackets {}. Anyone break it down for me? This I think is the hardest part of coding. Thanks!