Kvadratic - JS

Run Settings
LanguageJavaScript
Language Version
Run Command
function kvadratic(a,b,c) { const disc = discrim(a,b,c) if(disc < 0) { return "Diskriminant je zaporny, koren neexistuje pro realna cisla." } if(disc === 0) { return one_root(a,b) } return two_roots(a,b, disc) } function discrim(a,b,c) { return b * b - 4 * a * c } function one_root(a,b) { return [-b / (2 * a)] } function two_roots(a,b,disc) { const root1 = (-b + Math.sqrt(disc)) / (2 * a) const root2 = (-b - Math.sqrt(disc)) / (2 * a) return [root1, root2] } console.log(kvadratic(2,6,-20))
Editor Settings
Theme
Key bindings
Full width
Lines