I wrote this script based on information I read here on Stack. It calls data from an API and is supposed to convert the directional degrees to cardinal. When I run it, I get no output. There is no error when I inspect the page. I found no syntax errors when I ran it through Fiddle.
I thought I could simply substitute a number (I tried 45) for num and get the script to run to no avail so I could use an expert eye. Thank you.
var settings = {
"url": "https://api.stormglass.io/v1/weather/point?lat=40.370181&lng=-73.934193&key=...",
"method": "GET",
"timeout": 0,
};
$.ajax(settings)
.fail(function(a,b,c) { console.log(a.responseJSON) })
.done(function(response) {
console.log(response);
variconwndr24 = function degToCompass(num) {
var num = response.hours[17].windDirection[1].value;;
while (num < 0) num += 360;
while (num >= 360) num -= 360;
val = Math.round((num - 11.25) / 22.5);
arr = ["N", "NNE", "NE", "ENE", "E", "ESE", "SE",
"SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW"
];
return arr[Math.abs(val)];
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
{"errors":{"key":"API quota exceeded"},"meta":{"dailyQuota":50,"requestCount":51}}.fail(function(a,b,c) { console.log(a.responseJSON) })it tells you all you need to knownum, then immediately creating a new variable namednumequal to something else... You're also not callingvariconwndr24anywhere.