Friendly date Ranges Help

Friendly date Ranges Help
0

#1

I can not write condition for the challenge 3 because it seems alike the 2 challenge so I could not pass it. Here my code:

function makeFriendlyDates(arr) {

var dateStr1=arr[0];
var dateStr2=arr[1];

var day1, day2;
var month1,month2;
var year1,year2;

day1=new Date(dateStr1).getUTCDate();
day2=new Date(dateStr2).getUTCDate();

month1=new Date(dateStr1).getMonth();
month2=new Date(dateStr2).getUTCMonth();

year1=new Date(dateStr1).getFullYear();
year2=new Date(dateStr2).getFullYear();

var months=[‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’];
function dayNumbers(days){
switch (days){
case 1:
case 21:
case 31:
return days +“st”;
case 2:
case 22:
return days +“nd”;
case 3:
case 23:
return days+“rd”;
default:
return days +“th”;
}
}
if(day1===day2 && month1===month2 && year1===year2){
return [months[month1]+" “+dayNumbers(day1)+”,"+" “+year1];
}
if(day1===day2 && month1===month2){
return [months[month1]+” “+dayNumbers(day1)+”,"+" “+year1,months[month2]+” “+dayNumbers(day2)+”,"+" “+year2];
}
if(month1===month2 && year1===year2){
return [months[month1]+” “+dayNumbers(day1),dayNumbers(day2)];
}
if(month1===month2){
return [months[month1]+” “+dayNumbers(day1)+”,"+" “+year1,months[month2]+” “+dayNumbers(day2)];
}
if(year1===year2) {
return [months[month1]+” “+dayNumbers(day1)+”,"+" “+year1,months[month2]+” "+dayNumbers(day2)];
}

if(month1-month2<12 && day2-day1>0){
return [months[month1]+" “+dayNumbers(day1),months[month2]+” "+dayNumbers(day2)];
}

if(month1-month2<=12 && year1!==year2){
return [months[month1]+" “+dayNumbers(day1)+”," +" “+year1,months[month2]+” “+dayNumbers(day2)+”,"+" "+year2]; > // this condition is for the 3rd challenge
}
}
makeFriendlyDates([“2016-12-01”, “2018-02-03”]);


#2

month1 will be a string at this point. Change it to a number like this

months[+month1]

See if that helps.