I have wind direction data coming from a weather vane, and the data is represented in 0 to 359 degrees.
I want to convert this into text format (compass rose) with 16 di
If you arrived here and are only interested in breaking your degrees into one of 8 directions.
function degToCompass(num){ const val = Math.floor((num / 45) + 0.5); const arr = ["N","NE","E", "SE","S","SW","W","NW"]; return arr[(val % 8)]