Skip to content

Instantly share code, notes, and snippets.

@Maximilianos
Created June 25, 2015 13:00
Show Gist options
  • Save Maximilianos/824e29bdb2e6d172afcb to your computer and use it in GitHub Desktop.
Save Maximilianos/824e29bdb2e6d172afcb to your computer and use it in GitHub Desktop.
/**
* Kilometers per hour to
* Beaufort scale
*
* @param kmh
* @returns {number}
*/
function kmh2bf(kmh) {
var bf = 0;
var i = 0;
var scale = [
1.1,
5.5,
11.9,
19.7,
28.7,
38.8,
49.9,
61.8,
74.6,
88.1,
102.4,
117.4
];
while (scale[i] && kmh >= scale[i++]) {
bf = i;
}
return bf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment