When you want to sell a MacBook, it's a good idea to wipe all the data on it and sell it factory settings. If you factory reset your MacBook, your MacBook will also look more "fresh" in the eyes of the buyer. Make sure you have an Internet connection before resetting your MacBook.
Step
Method 1 of 2: Clearing Storage Media

Step 1. Restart your MacBook by clicking the Apple icon at the top left of the screen and selecting “Restart
”

Step 2. When the MacBook starts up and the screen is grayed out, press Command + R
Step 3. Select a Wi-Fi network (this option may not be available)

Step 4. Select “Disk Utility
”

Step 5. Delete the storage media
Select your drive from the list, then click “Erase.”

Step 6. Select “Mac OS Extended (Journaled)”
This option will appear in a new window.

Step 7. Give a new name for the storage media

Step 8. Click "Erase
" This will wipe your drive clean.
Method 2 of 2: Reinstalling the Operating System

Step 1. Exit Disk Utility after the wipe is complete
Click "Disk Utility," then "Quit Disk Utility."

Step 2. Reinstall OS X
Click "Continue".