How to calculate when is thanks giving day in javascript

So here is the code I saw people said that work, but the problem is that next year (2019) november the week has two days. So thank giving is so 5 week but the code say it is the week before. So please help. So here is the code:

function thanksgiving(theyear){
        var nov1stDay = new Date(theyear, 10, 1, 0, 0, 0, 0);
        var dayOfWeek = nov1stDay.getDay();
        var tgDayOfMonth = nov1stDay.getDate() - (dayOfWeek - 4) + 21;
        return 10 + '.' + tgDayOfMonth;
        if(tgDayOfMonth == 21){
           tgDayOfMonth = 28;
        }
        else{
            tgDayOfMonth = nov1stDay.getDate() - (dayOfWeek - 4) + 21;
        }
    }
console.log(thanksgiving(2019)); 

It will say 10.21

It doesn’t matter I have figure it out already but if you can make the code more simply. Thank you

howabout this?

function thanksgiving(theyear) {
  const lastOfNov = new Date(theyear, 10, 30).getDay();
  const turkyDay = (lastOfNov >= 4 ? 34 : 27) - lastOfNov;
  return `10.${turkyDay}`;
}

Thank but can you help me so I can calculate every holiday that changes date every year thank you.

can you link the exercise?

there is no exercise

Oh? So what is the problem for? What code do you have so far? Which holidays are you needing to track?

Don’t worry I have finished my task so I don’t need any more help. Thank you By the way