DEV Community

Discussion on: Daily Challenge #27 - Unlucky Days

Collapse
 
phallstrom profile image
Philip Hallstrom • Edited
require "date"

def unlucky_days(year)
  unlucky = 0
  1.upto(12).each do |month|
    date = Date.new(year, month, 13)
    unlucky += 1 if date.wday == 5
  end
  unlucky
end