A Friend Code is a special identifying code that everyone who uses on Nintendo WiFi Connection has. The DS, due to lacking any kind of account system, had friend codes for each game. On the Wii, DS and 3DS, both players are required to enter each other's friend code. On the 3DS, players do have the option of trading friend codes locally via infrared and certain games like Animal Crossing: New Leaf allow players to add friends they play regularly with.
Starting with the Wii U, Nintendo has discontinued the use of friend codes, and have replaced them with a Nintendo Network ID. They have started using them again with the Nintendo Switch. The Switch version of Friend Codes are not required with a number of options like adding via Nintendo Network ID, Twitter and recent players as well as local exchange.