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

Ka/w5 d2 #70

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Ka/w5 d2 #70

wants to merge 11 commits into from

Conversation

kevalwell
Copy link

},
divide: function(x,y) {
if (y==0) {
return "Do not divide by zero."

Choose a reason for hiding this comment

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

It's pretty weird to have a function that sometimes returns a float and sometimes returns a string. I'd just return x / y and let JS division semantics sort it out.

It turns out that dividing by zero returns Infinity:

>> 2 / 0
Infinity

Which is probably what you want anyway.

Copy link
Author

Choose a reason for hiding this comment

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

Thank you. Good Point I will make revisions.

On Thu, Mar 26, 2015 at 11:22 AM, queerviolet notifications@github.com
wrote:

In public/main.js
#70 (comment)
:

@@ -0,0 +1,36 @@
+var calculator = {

  • add: function (x,y){
  • return x + y;
  • },
  • subtract: function(x,y) {
  • return x - y;
  • },
  • multiply: function(x,y) {
  • return x * y;
  • },
  • divide: function(x,y) {
  • if (y==0) {
  •  return "Do not divide by zero."
    

It's pretty weird to have a function that sometimes returns a float and
sometimes returns a string. I'd just return x / y and let JS division
semantics sort it out.

It turns out that dividing by zero returns Infinity:

2 / 0
Infinity

Which is probably what you want anyway.


Reply to this email directly or view it on GitHub
https://github.com/nyc-sea-lions-2015/lightsaber/pull/70/files#r27222659
.

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