I want to use the weather api that when given for example the wind speed instead of the speed, display a custom message. I understand i have to use the IF block but i'm having a hard time wrapping my head around what is the structure i should follow.
After having that formula, I will hook it up with the current wind value in the front and just add the formula to "translate" the value to text.
function wind(speed) {
if (speed < 0.2) {
return {
description: "Calm",
recommendation: "Enjoy the quiet weather; it's like nature's lullaby."
};
} else if (speed >= 0.3 && speed <= 1.5) {
return {
description: "Light air",
recommendation: "Perfect breeze for a leisurely stroll or bike ride."
};
} else if (speed >= 1.6 && speed <= 3.3) {
return {
description: "Light breeze",
recommendation: "It's breezy but not too strong; perfect for outdoor activities. Secure your hat or scarf if you're out."
};
} else if (speed >= 3.4 && speed <= 5.4) {
return {
description: "Gentle breeze",
recommendation: "A gentle breeze is blowing; make sure your hat stays put!"
};
} else if (speed >= 5.5 && speed <= 7.9) {
return {
description: "Moderate breeze",
recommendation: "Hold onto your hats, folks! The wind is picking up a bit."
};
} else if (speed >= 8.0 && speed <= 10.7) {
return {
description: "Fresh breeze",
recommendation: "A fresh breeze is blowing; bring a light jacket just in case."
};
} else if (speed >= 10.8 && speed <= 13.8) {
return {
description: "Strong breeze",
recommendation: "Hang onto your hats! It's getting windy out there. Secure any loose items and maybe choose a hairstyle that can handle the wind."
};
……