Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

darts: Add new exercise #498

Merged
merged 6 commits into from
Oct 28, 2018
Merged

darts: Add new exercise #498

merged 6 commits into from
Oct 28, 2018

Conversation

ramadis
Copy link
Contributor

@ramadis ramadis commented Oct 9, 2018

Implementation in javascript of the exercise darts. PR in problem-specification here: exercism/problem-specifications#1363

@ramadis ramadis changed the title Add exercise 'target' darts: Add new exercise Oct 9, 2018
Copy link
Contributor

@matthewmorgan matthewmorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ramadis Thanks very much for adding this new exercise!

I have a couple of change requests, primarily stylistic. Also, you will need to update the config to add your new exercise. I don't think the build server actually ran your code, which might explain why the linter didn't complain about the module's main signature.

Please let me know if you have any questions or if I can help further.

@@ -0,0 +1,17 @@
export default function solve(x, y) {
// Define as numbers
x = Number(x);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should avoid re-assigning the input params. I'm surprised the linter didn't complain about this. We're currently using the Airbnb style guide: http://airbnb.io/javascript/#functions--mutate-params

expect(solve(x, y)).toEqual(expected);
});

test('A dart lands just in the border of the target', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests but the first should be disabled with xtest rather than test.

y = Number(y);

// Check for NaN
if (x !== x || y !== y) return null;
Copy link
Contributor

@matthewmorgan matthewmorgan Oct 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be more semantic and validate as early as possible, before the Number() calls. Actually using isNaN will mean we don't need the comment here:

if (isNaN(x) || isNaN(y)) return null;

@matthewmorgan
Copy link
Contributor

@ramadis did you need any help making these changes, or did you have questions or concerns about them? Let me know where you're at. Thanks!

@ramadis
Copy link
Contributor Author

ramadis commented Oct 20, 2018

@matthewmorgan I was actually wrapping up some details on the problem specification, so I can update all the fixes that were made there. I hope they approve that PR this week so I can update this one!

@ramadis
Copy link
Contributor Author

ramadis commented Oct 24, 2018

@matthewmorgan could you help me with the error thrown by travis? It says ./exercises/darts/package.json does not match main package.json but I run a diff between both files and they are exactly the same. Not sure what is it!

Edit: I also run make test and everything seems just OK.

@matthewmorgan
Copy link
Contributor

matthewmorgan commented Oct 26, 2018

@ramadis when I pull your branch and run make test-travis, the build fails (this is the make task that Travis uses, which checks the package.json files.)

Closer inspection reveals that you have a mismatch in your babel-preset-env dependency . If you run make test locally, it should copy the global package.json to each exercise project.

git diff


diff --git a/exercises/darts/package.json b/exercises/darts/package.json
index f625e85..af94361 100644
--- a/exercises/darts/package.json
+++ b/exercises/darts/package.json
@@ -12,7 +12,7 @@
     "babel-eslint": "^10.0.1",
     "babel-jest": "^21.2.0",
     "babel-plugin-transform-builtin-extend": "^1.1.2",
-    "babel-preset-env": "^1.4.0",
+    "babel-preset-env": "^1.7.0",
     "eslint": "^5.6.0",
     "eslint-config-airbnb-base": "^13.1.0",
     "eslint-plugin-import": "^2.14.0",

You'll need to commit that change and push to this branch again.

@matthewmorgan matthewmorgan merged commit c261c3f into exercism:master Oct 28, 2018
@matthewmorgan
Copy link
Contributor

Thanks @ramadis !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants