Added additional comments explaining the math. Changed output to console.log and tested.