These are chat archives for camperbot/bonfire-friendly-date-ranges

18th
Mar 2016
Himad Mouhtar
@hmouhtar
Mar 18 2016 02:37
hint
CamperBot
@camperbot
Mar 18 2016 02:37

hint [1/1]

## :construction: After this are possible spoiler hints.

Make sure you've tried to hard to solve it yourself before proceeding. :construction:

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Himad Mouhtar
@hmouhtar
Mar 18 2016 02:37
hint
CamperBot
@camperbot
Mar 18 2016 02:37
These hints depend on people like you! Please add to this :point_right: Bonfire's Wiki Hints Page
Sarah Sivilich
@ssivilich
Mar 18 2016 18:00
I'm having a problem with the test cases. Some of my outputs are exactly what they should be, and yet no green check mark....
function friendly(arr) {

var day1 = arr[0].substring(8,10);
var day2 = arr[1].substring(8,10);
if (day1 < 10){
  day1 = arr[0].substring(9,10);
}
if(day1 ==1){
  day1 += "st";
}
  else if(day1 ==2){
  day1 += "nd";
}
  else if(day1 ==3){
  day1 += "rd";
} 
  else{
  day1 += "th";
  }
  if (day2 < 10){
  day2 = arr[1].substring(9,10);
}
if(day2 ==1){
  day2 += "st";
}
  else if(day2 ==2){
  day2 += "nd";
}
  else if(day2 ==3){
  day2 += "rd";
} 
  else{
  day2 += "th";
  }

var months = ["0","January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];  

var month1 = arr[0].substring(5,7);
var month2 = arr[1].substring(5,7);

 if (month1 < 10){
  month1 = arr[0].substring(6,7);
  month1 = months[month1];

} 
  else{
    month1 = months[month1];
}
   if (month2 < 10){
  month2 = arr[1].substring(6,7);
  month2 = months[month2];

} 
  else{
    month2 = months[month2];
}

  var year1 =arr[0].substring(0,4);
  var year2 =arr[1].substring(0,4);

  var date1 = month1 + " " + day1 + ", " + year1;
  var date2 = month2 + " " + day2 + ", " + year2;

  if(day1 == day2 && year1 == year2 && month1 == month2){
    return date1;
  }  
  if(year1 == year2){
    date1 = month1 + " " + day1 + ", " + year1;
    date2 = month2 + " " + day2;
  }
  if(month1 == month2){
    date1 = month1 + " " + day1;
    date2 = day2;  
  }

return [date1, date2];
}

friendly(["2016-07-01", "2016-07-04"]);
Duane Bender
@dbender
Mar 18 2016 22:38
@ssivilich : Rename your function and the function call to makeFriendlyDates and you should get green check marks on 3 of the cases. The others fail for logic reasons. For example, you don't check for date1 being the current year, so you're returning the year 2016 when it should be omitted.