-
Notifications
You must be signed in to change notification settings - Fork 10
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
base: master
Are you sure you want to change the base?
Ka/w5 d2 #70
Conversation
Ka/environment files
}, | ||
divide: function(x,y) { | ||
if (y==0) { | ||
return "Do not divide by zero." |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
InfinityWhich 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
.
@linkblaine