{"action":"created","issue":{"url":"https://api.github.com/repos/exercism/xjavascript/issues/282","repository_url":"https://api.github.com/repos/exercism/xjavascript","labels_url":"https://api.github.com/repos/exercism/xjavascript/issues/282/labels{/name}","comments_url":"https://api.github.com/repos/exercism/xjavascript/issues/282/comments","events_url":"https://api.github.com/repos/exercism/xjavascript/issues/282/events","html_url":"https://github.com/exercism/xjavascript/issues/282","id":158054720,"number":282,"title":"leap year expects a JS class instead of simple function","user":{"login":"justgage","id":164033,"avatar_url":"https://avatars.githubusercontent.com/u/164033?v=3","gravatar_id":"","url":"https://api.github.com/users/justgage","html_url":"https://github.com/justgage","followers_url":"https://api.github.com/users/justgage/followers","following_url":"https://api.github.com/users/justgage/following{/other_user}","gists_url":"https://api.github.com/users/justgage/gists{/gist_id}","starred_url":"https://api.github.com/users/justgage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justgage/subscriptions","organizations_url":"https://api.github.com/users/justgage/orgs","repos_url":"https://api.github.com/users/justgage/repos","events_url":"https://api.github.com/users/justgage/events{/privacy}","received_events_url":"https://api.github.com/users/justgage/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-06-02T03:58:01Z","updated_at":"2016-06-08T01:39:33Z","closed_at":null,"body":" I find it odd that the [leap year](http://exercism.io/exercises/javascript/leap) exercise expects either a ES6 class or an old style sudo-classical class. I don't think that it's generally a good idea to encourage beginners towards classes in JavaScript especially in places where a simple function would do just fine like so:\r\n\r\n```js\r\n// have to pass in the year every time\r\nmodule.exports = (year) => { \r\n  !!(!(year % 4) && year % 100 || !(year % 400)); \r\n}\r\n```\r\nInstead of:\r\n\r\n```js\r\nmodule.exports = class Year {\r\n  constructor(year) {\r\n    this.year = year;\r\n  },\r\n  isLeap() {\r\n    return !!(!(this.year % 4) && this.year % 100 || !(this.year % 400));\r\n  }\r\n}\r\n```\r\n\r\nI'm guessing this is an artifact from the fact that it was ported from a Java exercise [http://www.javaranch.com/leap.jsp](http://www.javaranch.com/leap.jsp)"},"comment":{"url":"https://api.github.com/repos/exercism/xjavascript/issues/comments/224463902","html_url":"https://github.com/exercism/xjavascript/issues/282#issuecomment-224463902","issue_url":"https://api.github.com/repos/exercism/xjavascript/issues/282","id":224463902,"user":{"login":"justgage","id":164033,"avatar_url":"https://avatars.githubusercontent.com/u/164033?v=3","gravatar_id":"","url":"https://api.github.com/users/justgage","html_url":"https://github.com/justgage","followers_url":"https://api.github.com/users/justgage/followers","following_url":"https://api.github.com/users/justgage/following{/other_user}","gists_url":"https://api.github.com/users/justgage/gists{/gist_id}","starred_url":"https://api.github.com/users/justgage/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justgage/subscriptions","organizations_url":"https://api.github.com/users/justgage/orgs","repos_url":"https://api.github.com/users/justgage/repos","events_url":"https://api.github.com/users/justgage/events{/privacy}","received_events_url":"https://api.github.com/users/justgage/received_events","type":"User","site_admin":false},"created_at":"2016-06-08T01:39:33Z","updated_at":"2016-06-08T01:39:33Z","body":"@matthewmorgan Wow, I learned something today! I tried the following code:\r\n\r\n```\r\nmodule.exports = (year) => {\r\n  return {\r\n    isLeap() {\r\n      return !!(!(year % 4) &&\r\n                year % 100 ||\r\n                !(year % 400));\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nWhich creates the following error:\r\n```\r\nλ ~/exercism/javascript/leap/ jasmine-node leap.spec.js\r\nFFFFFFFF\r\n\r\nFailures:\r\n\r\n  1) Leap year is not very common\r\n   Message:\r\n     TypeError: Year is not a constructor\r\n   Stacktrace:\r\n     TypeError: Year is not a constructor\r\n    at .<anonymous> (/home/justgage/exercism/javascript/leap/leap.spec.js:6:16)\r\n...\r\n```\r\n\r\nHowever changing it to `function` fixes this. Turns out I learned something about some of the differences of arrow functions!\r\n\r\nHowever I do feel that the __very presence__ of the `new` operator leads people to use solve the problem with pseudo-classical inheritance (possibly due to [googling it](https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8&client=ubuntu#q=javascript%20new))\r\n\r\nI took a short sample of posts this is about what I get as far as how people solve it:\r\n```\r\nthe 'revealing' pattern: 1\r\nConstructor Functions:   1111111111111111111111111111\r\nES6 Class:               1111\r\n```\r\n\r\nIt seems like as x goes to infinity the constructor function becomes the only way to solve it :P. \r\n\r\nEither way I feel satisfied that I can at least guide people to a better way now, although I do wish the exercise was better about leading people to better patterns. "}}
{"actor":{"display_login":"justgage"}}