- 1

Javascript question

I wanted to create a quadratic equation solver but I stopped here.Who can help me to find my mistake: let a=prompt("Give value for a") let b=prompt("Give value for b") let c=prompt("Give value for c") let d=confirm( Math.pow(b,2)-4*a*c) if(d>0) alert((-b+Math.sqrt(d))/2 * a) alert((-b-Math.sqrt(d))/2 * a)

6th Aug 2019, 9:17 AM
Dav
Dav - avatar
3 odpowiedzi
+ 2
parse the inputs from the prompt as int, otherwise a, b, c and d will all be Strings... so: let a = parseInt(prompt("Give value for a"); ... what errors are happening? Is it an logic error or an runtime error? 😅
6th Aug 2019, 10:21 AM
Anton Böhler
Anton Böhler - avatar
+ 2
or parseFloat() would actually make more sense ...
6th Aug 2019, 10:22 AM
Anton Böhler
Anton Böhler - avatar
+ 1
Thank you for your help😉
6th Aug 2019, 10:40 AM
Dav
Dav - avatar