From Wikipedia:
Each state has a number of electors equal to the number of its Senators and Representatives in the United States Congress. Additionally, Washington, D.C. is given a number of electors equal to the number held by the "least populous" state. U.S. territories are not represented in the Electoral College.
[...]
The Constitution allows each state legislature to designate a method of choosing electors. Forty-eight states and the District of Columbia have adopted a winner-take-all popular vote rule where voters choose between statewide slates of electors pledged to vote for a specific presidential and vice presidential candidate. The candidate that wins the most votes in the state wins the support of all of that state’s electors. The two other states, Maine and Nebraska, use a tiered system where a single elector is chosen within each Congressional district and two electors are chosen by statewide popular vote. U.S. presidential elections are effectively an amalgamation of 51 separate and simultaneous elections (50 states plus the District of Columbia), rather than a single national election.