* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.5 KiB
1.5 KiB
id, title, challengeType, forumTopicId, dashedName
| id | title | challengeType | forumTopicId | dashedName |
|---|---|---|---|---|
| 5a23c84252665b21eecc7edc | Last Friday of each month | 5 | 302299 | last-friday-of-each-month |
--description--
Write a function that returns the date of the last Friday of a given month for a given year.
--hints--
lastFriday should be a function.
assert(typeof lastFriday == 'function');
lastFriday(2018, 1) should return a number.
assert(typeof lastFriday(2018, 1) == 'number');
lastFriday(2018, 1) should return 26.
assert.equal(lastFriday(2018, 1), 26);
lastFriday(2017, 2) should return 24.
assert.equal(lastFriday(2017, 2), 24);
lastFriday(2012, 3) should return 30.
assert.equal(lastFriday(2012, 3), 30);
lastFriday(1900, 4) should return 27.
assert.equal(lastFriday(1900, 4), 27);
lastFriday(2000, 5) should return 26.
assert.equal(lastFriday(2000, 5), 26);
lastFriday(2006, 6) should return 30.
assert.equal(lastFriday(2006, 6), 30);
lastFriday(2010, 7) should return 30.
assert.equal(lastFriday(2010, 7), 30);
lastFriday(2005, 8) should return 26.
assert.equal(lastFriday(2005, 8), 26);
--seed--
--seed-contents--
function lastFriday(year, month) {
}
--solutions--
function lastFriday(year, month) {
var i, last_day;
i = 0;
while (true) {
last_day = new Date(year, month, i);
if (last_day.getDay() === 5) {
return last_day.getDate();
}
i -= 1;
}
}