Skip to content

Instantly share code, notes, and snippets.

@NickChen14
Created July 19, 2021 04:16
Show Gist options
  • Save NickChen14/3cc9aea71188ceea020e150a90d312f2 to your computer and use it in GitHub Desktop.
Save NickChen14/3cc9aea71188ceea020e150a90d312f2 to your computer and use it in GitHub Desktop.
Dayofweek - en96321
// 修改前
function solution(S, K) {
const d = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
const nowDat = d.findIndex(item => item === S)
const add = K % 7
if (add <= 6 - nowDat) {
return d[nowDat + add]
}
return d[add - (6 - nowDat + 1)]
// write your code in JavaScript (Node.js 8.9.4)
}
// 修改後
function solution (S, K) {
const dat = ['Mon', 'Tue', 'Wed', 'Sur', 'Fri', 'Sat', 'Sun']
const nowDat = dat.findIndex(d => d === S)
return dat[(nowDat + K) % 7]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment