diff --git a/challenges/01-front-end-development-certification/advanced-bonfires.json b/challenges/01-front-end-development-certification/advanced-bonfires.json index 6edc003cde..7948385a97 100644 --- a/challenges/01-front-end-development-certification/advanced-bonfires.json +++ b/challenges/01-front-end-development-certification/advanced-bonfires.json @@ -378,87 +378,6 @@ } } }, - { - "id": "a19f0fbe1872186acd434d5a", - "title": "Friendly Date Ranges", - "description": [ - "Convert a date range consisting of two dates formatted as YYYY-MM-DD into a more readable format.", - "The friendly display should use month names instead of numbers and ordinal dates instead of cardinal (1st instead of 1).", - "Do not display information that is redundant or that can be inferred by the user: if the date range ends in less than a year from when it begins, do not display the ending year.", - "Additionally, if the date range begins in the current year (i.e. it is currently the year 2016) and ends within one year, the year should not be displayed at the beginning of the friendly range.", - "If the range ends in the same month that it begins, do not display the ending year or month.", - "Examples:", - "makeFriendlyDates([\"2016-07-01\", \"2016-07-04\"]) should return [\"July 1st\",\"4th\"]", - "makeFriendlyDates([\"2016-07-01\", \"2018-07-04\"]) should return [\"July 1st, 2016\", \"July 4th, 2018\"].", - "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code." - ], - "challengeSeed": [ - "function makeFriendlyDates(arr) {", - " return arr;", - "}", - "", - "makeFriendlyDates(['2016-07-01', '2016-07-04']);" - ], - "solutions": [ - "function makeFriendlyDates(str) {\n var thisYear = new Date().getFullYear();\n var dates = str.map(function(s) {return s.split('-').map(Number);});\n var start = dates[0];\n var end = dates[1];\n if (str[0] === str[1]) {\n return [readable(start)];\n }\n if (start[0] !== end[0]) {\n if (start[0] + 1 === end[0]){\n if (start[1] > end[1]){\n end[0] = undefined;\n }\n if (start[1] === end[1] && start[2] > end[2]){\n end[0] = undefined;\n }\n if (start[0] === thisYear){\n start[0] = undefined;\n }\n }\n return dates.map(readable);\n }\n end[0] = undefined;\n if (start[0] === thisYear){\n start[0] = undefined;\n }\n if (start[1] === end[1]) {\n end[1] = undefined;\n }\n return dates.map(readable);\n}\n\nfunction readable(arr) {\n var ordD = arr[2] + nth(arr[2]);\n if (!arr[1]) {\n return ordD;\n }\n return MONTH[arr[1]] + \" \" + ordD + (!arr[0] ? \"\" : \", \" + arr[0]);\n}\n\nvar MONTH = {1: \"January\",\n 2: \"February\",\n 3: \"March\",\n 4: \"April\",\n 5: \"May\",\n 6: \"June\",\n 7: \"July\",\n 8: \"August\",\n 9: \"September\",\n 10: \"October\",\n 11: \"November\",\n 12: \"December\"};\n\nfunction nth(d) {\n if(d>3 && d<21) return 'th';\n switch (d % 10) {\n case 1: return \"st\";\n case 2: return \"nd\";\n case 3: return \"rd\";\n default: return \"th\";\n }\n}" - ], - "tests": [ - "assert.deepEqual(makeFriendlyDates(['2016-07-01', '2016-07-04']), ['July 1st','4th'], 'message: makeFriendlyDates([\"2016-07-01\", \"2016-07-04\"]) should return [\"July 1st\",\"4th\"].');", - "assert.deepEqual(makeFriendlyDates(['2016-12-01', '2017-02-03']), ['December 1st','February 3rd'], 'message: makeFriendlyDates([\"2016-12-01\", \"2017-02-03\"]) should return [\"December 1st\",\"February 3rd\"].');", - "assert.deepEqual(makeFriendlyDates(['2016-12-01', '2018-02-03']), ['December 1st, 2016','February 3rd, 2018'], 'message: makeFriendlyDates([\"2016-12-01\", \"2018-02-03\"]) should return [\"December 1st, 2016\",\"February 3rd, 2018\"].');", - "assert.deepEqual(makeFriendlyDates(['2017-03-01', '2017-05-05']), ['March 1st, 2017','May 5th'], 'message: makeFriendlyDates([\"2017-03-01\", \"2017-05-05\"]) should return [\"March 1st, 2017\",\"May 5th\"]');", - "assert.deepEqual(makeFriendlyDates(['2018-01-13', '2018-01-13']), ['January 13th, 2018'], 'message: makeFriendlyDates([\"2018-01-13\", \"2018-01-13\"]) should return [\"January 13th, 2018\"].');", - "assert.deepEqual(makeFriendlyDates(['2022-09-22', '2023-09-21']), ['September 22nd, 2022','September 21st'], 'message: makeFriendlyDates([\"2022-09-22\", \"2023-09-21\"]) should return [\"September 22nd, 2022\",\"September 21st\"].');", - "assert.deepEqual(makeFriendlyDates(['2022-09-05', '2023-09-05']), ['September 5th, 2022','September 5th, 2023'], 'message: makeFriendlyDates([\"2022-09-05\", \"2023-09-05\"]) should return [\"September 5th, 2022\",\"September 5th, 2023\"].');" - ], - "type": "bonfire", - "MDNlinks": [ - "String.prototype.split()", - "String.prototype.substr()", - "parseInt()" - ], - "challengeType": 5, - "translations": { - "es": { - "title": "Rangos de Fechas Amigables", - "description": [ - "Convierte un rango de fecha que conste de dos fechas en formato AAAA-MM-DD a un formato más legible", - "", - "La presentación amigable debería usar nombres de meses en inglés en lugar de números y fechas ordinales en lugar de cardinales (\"1st\" en lugar de \"1\").", - "No presentes información redundante o que pueda ser inferida por el usuario: si el rango de fechas termina en menos de un año desde la fecha incial, no presentes el año final. Si el rango termina en el mismo mes de la fecha inicial, no presentes ni el mes ni el año final.", - "Además, si el rango de fechas comienza en el año actual y termina en un año o menos, no debes presentar el año al comienzo del rango amigable." - ] - }, - "it": { - "title": "Intervalli di Date Leggibili", - "description": [ - "Converti un intervallo di date composto da due date in formato YYYY-MM-DD in un formato più leggibile.", - "Il formato leggibile deve usare i nomi dei mesi (in inglese) e le i numeri dei giorni in formato ordinale invece che cardinale (sempre in inglese. Ad esempio 1st invece di 1).", - "Non mostrare informazioni ridondanti o che siano ricavabili dall'utente: se l'intervallo di date termina in meno di un anno da quando inizia, non mostrare l'anno in cui l'intervallo termina.", - "In più, se l'intervallo di date incomincia nell'anno corrente (siamo nell'anno 2016) e finisce nel giro di un anno, l'anno non deve essere mostrato all'inizio del risultato.", - "Se l'intervallo di date finisce nello stesso mese in cui incomincia, non mostrare l'anno di termine nè il mese.", - "Esempi:", - "makeFriendlyDates([\"2016-07-01\", \"2016-07-04\"]) deve ritornare [\"July 1st\",\"4th\"]", - "makeFriendlyDates([\"2016-07-01\", \"2018-07-04\"]) deve ritornare [\"July 1st, 2016\", \"July 4th, 2018\"].", - "Ricorda di usare Leggi-Cerca-Chiedi se rimani bloccato. Prova a programmare in coppia. Scrivi il codice da te." - ] - }, - "pt-br": { - "title": "Intervalo de Datas Amigável", - "description": [ - "Converta um intervalo de tempo que consiste de duas datas formatadas como YYYY-MM-DD em um formato mais legível.", - "O resultado deve usar o nome dos meses ao invés de números e datas ordinais ao invés de cardinais(1st ao invés de 1).", - "Não mostre informação que é redundante ou que pode ser inferida pelo usuário: se o intevalo termina em menos de um ano da data de início, não mostre o ano na data final.", - "Além disso, se o intervalo começa no no ano atual (i.e. o ano atual é 2016) e termina no mesmo ano, o ano não deve ser mostrado no início do intevalo amigável.", - "Se o intervalo termina no mesmo mês em que começa, não mostre o ano e o mês na data final.", - "Examples:", - "makeFriendlyDates([\"2016-07-01\", \"2016-07-04\"]) deve retornar [\"July 1st\",\"4th\"]", - "makeFriendlyDates([\"2016-07-01\", \"2018-07-04\"]) deve retornar [\"July 1st, 2016\", \"July 4th, 2018\"].", - "Lembre-se de usar Ler-Procurar-Perguntar se você ficar preso. Tente programar em par. Escreva seu próprio código." - ] - } - } - }, { "id": "a2f1d72d9b908d0bd72bb9f6", "title": "Make a Person",