New Jersey passed a law in 2008 saying that its electoral vote would go to the national popular vote winner. It was part of a national compact and would only go into effect the number of electoral votes of the states in the compact adds up to a majority of the electoral votes (270).
You said...