JavaScript unit-converting calculator