mirror of
https://github.com/netbymatt/temperature-express.git
synced 2026-11-28 18:38:04 -08:00
13 lines
454 B
JavaScript
13 lines
454 B
JavaScript
// find wind direction, private
|
|
// finds wind direction in array of timestamp/wind directions pairs
|
|
const findWindDirection = (timestamp, windDirections = []) => {
|
|
let direction = 0; // default case
|
|
for (let i = 0; i < windDirections.length; i += 1) {
|
|
// exit loop if we've gone past the provided timestamp
|
|
if (windDirections[i][0] > timestamp) break;
|
|
[, direction] = windDirections[i];
|
|
}
|
|
return direction;
|
|
};
|
|
export default findWindDirection;
|