Skip to content

isEven -- Modulo issue #83

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

Closed
erictessin opened this issue Feb 11, 2021 · 5 comments
Closed

isEven -- Modulo issue #83

erictessin opened this issue Feb 11, 2021 · 5 comments

Comments

@erictessin
Copy link

Test will fail for "should not use modulo" when the word "modulo" is included in comments.

@mybrainishuge
Copy link
Contributor

Thanks for your feedback, @erictessin. Do you have a suggested solution for improving this test?

@erictessin
Copy link
Author

Hey @mybrainishuge!

Maybe delete this line in the test?

expect(stringified).to.not.contain('modulo');

Unless there is a way to calculate the remainder using the word "modulo" that i don't know about, I don't see why including the word should make the test fail. But maybe I'm missing something?

@mybrainishuge
Copy link
Contributor

mybrainishuge commented Feb 12, 2021

One of the challenges is to write a function called modulo. The test you referenced is attempting to prevent you from using that function.

var isEven = function(n) {
    return modulo(n, 2) === 0
};

^^^ This misses the point of the exercise since isEven doesn't call itself. Keep in mind that these challenges aren't expected to be performant, but rather force you to utilize recursion. More specifically, each function must call itself.

What's a base case for even or odd and how do you reach that base case? Think about factorial if you've already implemented that one. Given n, what can you do to n repeatedly until the base case is reached to determine the answer?

Does that help?

@mybrainishuge
Copy link
Contributor

I made a change to the check for modulo, but using it by name or operator is still forbidden when implementing isEven. I'm going to close this issue, but feel free to reach out if you have more questions.

@erictessin
Copy link
Author

erictessin commented Feb 14, 2021 via email

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

No branches or pull requests

2 participants