Skip to content

Commit

Permalink
Added relevant links math/QyadraticRoots and fixed let - const
Browse files Browse the repository at this point in the history
  • Loading branch information
chapati456 committed Sep 30, 2023
1 parent cc965eb commit 057bc64
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Maths/QuadraticRoots.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@

const quadraticRoots = (a, b, c) => {
// Calculate the discriminant
let discriminant = b * b - 4 * a * c
const discriminant = b * b - 4 * a * c

// Check if roots are real
if (discriminant < 0) {
return 'No real roots'
} else if (discriminant === 0) {
// One real root
let root = -b / (2 * a)
const root = -b / (2 * a)
return [root]
} else {
// Two real roots
let sqrtDiscriminant = Math.sqrt(discriminant)
let root1 = (-b + sqrtDiscriminant) / (2 * a)
let root2 = (-b - sqrtDiscriminant) / (2 * a)
const sqrtDiscriminant = Math.sqrt(discriminant)
const root1 = (-b + sqrtDiscriminant) / (2 * a)
const root2 = (-b - sqrtDiscriminant) / (2 * a)
return [root1, root2]
}
}
Expand Down

0 comments on commit 057bc64

Please sign in to comment.