Hello dear Developers. I need your advise. Which is the correct way to do that? Get the value from DOM and convert or re call of function with additional parameter (metric or imperial) which returns temperature value from API?
My prototype of the app:
See the Pen Weather app by Denis Nazarenko (@dnazarex) on CodePen.
Well, the result is the same for both methods, but one is done immediately while the other has a small delay. Which would you prefer as a user of your app?
Exactly first one, but the main reason ask about it, is… when i round value then convert to another units then round again then convert back and so on… I think the initial value will be little bit different than final. But I’m not sure). Anyway, thank you @marzelin.
Store your original un-rounded values in variables and use those in the conversion. Then use those again when you convert back. This way you always have solid data to work with.
Well, it’s quite quirky behaviour for someone to click multiple times on the convert button, but that’s a valid point, and as @rickstewart said, there’s a simple solution for that.