finishing js functions - now onto testing
tests finished code works