Complex sentence: During the War of 1812, he joined the military, and commanded the New Jersey State Militia at Sandy Hook, where his assignment was to prevent ships from attacking New York City.
Split into simpler sentences: During the War of 1812, he joined the military. He commanded the New Jersey State Militia at Sandy Hook, where his assignment was to prevent ships from attacking New York City.