首页 > 解决方案 > 如何解决条件 OR 问题

问题描述

我希望闰年和次年为“22”,其余为“23”。

var hdag = ((Date.isLeapYear(year) || (Date.isLeapYear(year)+1)) ? "23" : "22") + "/9";

标签: javascript

解决方案


我不完全确定你想做什么,因为这个问题写得很奇怪,但请试试这个:

let thisYear = (Date.isLeapYear(year)) ? "22" : "23") + "/9",
    nextYear = thisYear


console.log(`This year is ${thisYear}, and next year is ${nextYear}`)

推荐阅读