Which of these sentences is written correctly?

*
The kids went to the candy store, they bought a lot of candy!
The kids went to the candy store and they bought a lot of candy!
The kids went to the candy store, and they bought a lot of candy!
The kids went to the candy store they bought a lot of candy!

The sentence that is written correctly is:

"The kids went to the candy store and they bought a lot of candy!"

The first sentence ("The kids went to the candy store, they bought a lot of candy!") is an example of a comma splice, where two independent clauses are incorrectly joined by a comma without a coordinating conjunction.

The second sentence is the correct one and avoids the comma splice by using the coordinating conjunction "and" to join the two independent clauses.

The third sentence ("The kids went to the candy store, and they bought a lot of candy!") is also grammatically correct; however, the comma before "and" is not necessary because both clauses are short and closely related. According to certain style guides, such a comma is optional.

The fourth sentence ("The kids went to the candy store they bought a lot of candy!") is incorrect because it contains a run-on sentence; there's no punctuation or coordinating conjunction between the two independent clauses.