javascript calculate code