Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.7k
algorithm: quadratic formula#1151
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Maths/test/QuadraticFormula.test.js Outdated
@@ -0,0 +1,21 @@ | |||
import { quadraticFormula } from '../QuadraticFormula' | |||
test('Testing on quadraticFormula', () => { |
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.
Maths/QuadraticFormula.js Outdated
* @example quadraticFormula(1, -3, 8) = 'the roots do not exist or the roots are imaginary' | ||
*/ | ||
const quadraticFormula = (a, b, c) => { |
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.
Please rename tosolveQuadraticEquation
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.
Ok, no problem 👍
Maths/QuadraticFormula.js Outdated
} | ||
const discriminant = (b ** 2) - (4 * a * c) | ||
const denominator = 2 * a | ||
let answer = '' |
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.
Don't use strings; instead, return an array of solutions (empty array for no solutions, array with single item for one solution, two items for two solutions).
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.
Ok, I'll do that...thanks!
Maths/QuadraticFormula.js Outdated
if (typeof a !== 'number' || typeof b !== 'number' || typeof c !== 'number') { | ||
return new TypeError('Some argument is not a number.') | ||
} | ||
const discriminant = (b ** 2) - (4 * a * c) | ||
const denominator = 2 * a | ||
let answer ='' | ||
let answer =[] | ||
if (discriminant >= 0) { |
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.
Please distinguishdiscriminant == 0
here to only add a single item toanswer
in that case.
Uh oh!
There was an error while loading.Please reload this page.
Please don't forget to rename the file. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Uh oh!
There was an error while loading.Please reload this page.
Describe your change:
Checklist:
Example:
UserProfile.js
is allowed butuserprofile.js
,Userprofile.js
,user-Profile.js
,userProfile.js
are notFixes: #{$ISSUE_NO}
.