Creating and testing math functions in Javascript