an amalgamation (lol, thx sunsfan!) of js code for learning purposes.