I'm currently learning CoffeeScript, since it's more "expressive" than JavaScript, and therefore, I'd like to know how I would optimize the code that I have below
lastDay = 6
weekdays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
weeksToDivide = 0
for x in [1..9001]
if x % 5 == 0
if x % 4 == 0
if x % 3 == 0
nextDay = x
break
totalDays = lastDay + nextDay
day = (totalDays -= 7 while totalDays > 7)
weekday = weekdays[day[day.length - 1] - 1]
alert "Days until next meeting: #{nextDay}"
alert "That day is on a #{weekday}"
I'm mainly looking for a way to optimize the if nest, but any other tips would be appreciated too.
Thanks in advance.
EDIT:
I was being stupid and forgot how maths work, thanks Zeta.
Also, thanks to epidemian for further optimization.