我认为使用 if / if else 语句代码太多,我在一些网站上看到可以更好地简化嵌套条件,例如本网站上显示的一些示例 https://www.javascripttutorial.net/javascript-if-else/
我想在数组或这样的对象中获取风向名称 - let windNames = [Northerly','North Easterly','Easterly','South Easterly'...]
你们能帮我吗?
非常感谢。
function textDescription(d) {
{ //convert the wind direction as int to string
if (d > 0 && d < 20) {
return "Northerly";
} else if (d > 30 && d < 60) {
return "North easterly";
} else if (d > 55 && d < 100) {
return "Easterly";
} else if (d > 110 && d < 140) {
return "South …Run Code Online (Sandbox Code Playgroud)