JavaScript based simple calculator with pattern usage