Rewrite the temp and light program  in JavaScript