Public Solving: Calculating the wind chill

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
Search for a command to run...

I'm a full-stack developer from South Africa 🇿🇦. I love writing about JavaScript, HTML and CSS.
No comments yet. Be the first to comment.
Most of you know me for my consistency, a golden arrow in my blog series. I've written 1000 articles in 1008 days! Almost an article a day, and my honeymoon was the only holiday I ever took. I'm super proud of this achievement; it has been a fantasti...

It's not the first time I'll be talking about community. I think it's an essential aspect of any successful tool. This shows in my previous explorations of Astro, Medusa, and now Vendure as well. All these products thrive in a super open, welcoming, ...

The cool part about Vendure is how easy it is to set up and how abstract each layer is. Basically, we get the following elements: External database Server Worker Admin UI Frontend While this is amazing, it also brings a bit of complexity when it co...

The previous article looked at customizing Vendure on a data and process level. In this article, we'll look at customizing emails, as they are often a big part of a webshop system. We'll be looking at two different layers of customization for customi...

Even though Vendure is a pretty significant project out of the box, in some cases, we might want to go in and modify some elements to work to our specific use case. In this article, I'll take a high-level look at some elements we can customize within...

Santa's sled is pretty modern. Hey, we even upgraded it to have an autopilot. But now, the elves want to surprise Santa by adding a wind chill gauge.
The wind chill is the "feel" temperature, you know when it's like 30 degrees, but it feels like 35?
You can find the complete puzzle here.
To do this, we can use an already provided mathematical calculation which can be found here.
The wind chill can be calculated for English and Metric values.
The main thing we have to achieve today is to actually make the formula in JavaScript. This should be a pretty straightforward process.
The formula for English units looks like this:
35.74 + 0.6215T – 35.75 (V^0.16) + 0.4275T (V^0.16)
Where T = Temperature in degrees Fahrenheit and V = wind speed in miles per hour.
In JavaScript this should look similar to this:
35.74 + 0.6215 * temperature - 35.75 * windSpeed ** 0.16 + 0.4275 * temperature * windSpeed ** 0.16
Did you note the (V^0.16) exponent? We can use Math.pow or the shortcut ** for that.
Then we can simply wrap this in a Math.round to get the rounded number.
return Math.round(
35.74 +
0.6215 * temperature -
35.75 * windSpeed ** 0.16 +
0.4275 * temperature * windSpeed ** 0.16
);
However, we also need a way to calculate the metric version.
I decided to just catch and return the English units beforehand.
And if that didn't hit, surely it must be the metric version.
if (units === 'US') {
return Math.round(
35.74 +
0.6215 * temperature -
35.75 * windSpeed ** 0.16 +
0.4275 * temperature * windSpeed ** 0.16
);
}
return Math.round(
13.12 +
0.6215 * temperature -
11.37 * windSpeed ** 0.16 +
0.3965 * temperature * windSpeed ** 0.16
);
And that's it! We solved the issue.
Let's try it out and see if our test turns green.

Would love to hear what you would do differently to solve this problem.
Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on Facebook or Twitter