repl.it
@cmarmar/

unlucky days

ES6

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const unluckyDays = (year) => {
  const newYearsDay = new Date(year, 0, 1)
  let firstDayOfYear = newYearsDay.getDay()
  let firstFriday
  if (firstDayOfYear === 5) firstFriday = newYearsDay
  else if (firstDayOfYear < 5){
    const difference = 5 - firstDayOfYear

    firstFriday = firstDayOfYear.setDate(firstDayOfYear.getDay() + difference) 

    console.log(firstFriday)

  }
  else {
    console.log(newYearsDay)
  }
}



unluckyDays(2015)
Babel Compiler v6.4.4 Copyright (c) 2014-2015 Sebastian McKenzie