javascript - 如何解决条件 OR 问题
问题描述
我希望闰年和次年为“22”,其余为“23”。
var hdag = ((Date.isLeapYear(year) || (Date.isLeapYear(year)+1)) ? "23" : "22") + "/9";
解决方案
我不完全确定你想做什么,因为这个问题写得很奇怪,但请试试这个:
let thisYear = (Date.isLeapYear(year)) ? "22" : "23") + "/9",
nextYear = thisYear
console.log(`This year is ${thisYear}, and next year is ${nextYear}`)
推荐阅读
- javascript - 如何在api中将英制单位转换为公制单位?
- r - 给定分布 A 和空分布,如何找到对应于 FDR=0.05 的值?
- mysql - 可以使用子查询在 MySql 查询中分配 LIMIT 值吗?
- python - 为什么 Tensorflow/Keras Flatten 层不能展平我的阵列?
- spring-boot - Spring Boot - 如何创建独立的身份验证 MICROSERVICE?
- r - 如何让ggplot为每个刻度线显示一个标签
- microsoft-graph-api - 在 Ms Teams Graph beta API 中捕获自适应卡片响应
- c++ - 从排序列表中删除重复项(新方法)
- for-loop - Julia 中的 for 循环。语法混乱
- reactjs - 如何在 react-typescript 中设置 HOC 中的道具类型?