javascript sample implementation for a calculator