For young people, Massachusetts is the place to be, according to a new analysis from personal finance site WalletHub.

For its 2019 Best and Worst States for Millennials ranking, WalletHub looked at data pertaining to five key dimensions across the 50 states and Washington D.C.: affordability, education and health, quality of life, economic health and civic engagement. Within those dimensions, WalletHub analyzed dozens of metrics, including everything from cost of living and millennial home-ownership rate to average earnings growth for millennials and millennial voter turnout.

In the No. 1 spot, Massachusetts scored first in the education and health dimension, with the highest percentage of millennials with health insurance coverage. Massachusetts also scored second in the quality of life dimension and third in the economic health ranking.

The second best place for millennials, which is technically a federal district, is Washington, D.C., which boasted a first place ranking in the quality of life dimension, while also touting the title of having the highest average earnings for millennials.

Rounding out the top three is Washington state, boosted by its third place score in the affordability dimension, where it had the third highest average earnings for millennials.

These are the top 10 best states for millennials, according to WalletHub:

1. Massachusetts

2. District of Columbia (Washington D.C.)

3. Washington

4. Minnesota

5. Wisconsin

6. Colorado

7. Iowa

8. Utah

9. Pennsylvania

10. California

On the flip side, the worst state for millennials according to WalletHub, is West Virginia, with a high unemployment rate among millennials and a high percentage of millennials with depression. The second worst state for millennials, according to the analysis, is New Mexico (with a high millennial unemployment rate), followed by Mississippi (with low average earnings for millennials, a high millennial unemployment rate and a low percentage of millennials with health insurance coverage).

These are the 10 worst states for millennials, according to WalletHub:

1. West Virginia

2. New Mexico

3. Mississippi

4. Oklahoma

5. Louisiana

6. Arkansas

7. Nevada

8. Kentucky

9. South Carolina

10. Alabama

You can check out WalletHub's full ranking and methodology here.

Don't miss: These are the 10 best cities for work-life balance

Like this story? Subscribe to CNBC Make It on YouTube!