This appears to be a walkthrough for a browser-based or fan-made game, not an official release. The JavaScript snippet shows a typical inventory/puzzle logic:
There is no universal "code" — this is game logic. If you're playing a specific flash/HTML5 game, the code is embedded in that game's source. For official SpongeBob games, consult the game's guide or wiki.