How many times have you stopped and said to yourself, "I wish I know the slope of that line?" Yeah -- me too! That's what this script is all about. It finds the slope of the line for you.
/*This script was made by Michael Finnegan. I have given permission for www.htmlgoodies.com to post this script for public use. I do, however, ask that if you do use this script, to please leave this comment in place. Thank you! I would also like to thank Joe Burns and Andree Growney for providing such a wonderful series of JavaScript primers. They were exceptionally well written and helped tremendously!*/ //This script was finished on Friday, October 9, 1998. //You may email me at snobord15@hotmail.com var x1=prompt("What would you like coordinate x1 to be?") var y1=prompt("What would you like coordinate y1 to be?") var x2=prompt("What would you like coordinate x2 to be?") var y2=prompt("What would you like coordinate y2 to be?") var y3 = y1-y2 var x3 = x1-x2 var slope = y3/x3 var z1 = slope*x1 var z2 = -1*y1 var z3 = z1+z2 var z4 = -1*z3 alert("The slope of the line formed by points " + x1+"," + y1+ " and " + x2+ "," + y2+ " is " + slope) alert("The y intercept of this line is "+ z4+". The equation of the line is: y="+ slope+"x+"+ z4)
Please note: This script is being offered in simple text format. When you click to Grab the Script, the text should display. Internet Explorer and AOL users may get a blank page or the script may run and produce the effect. If this happens, choose SAVE AS from the FILE menu and save the blank or compiled page.