// Add your JavaScript here. jQuery, Bootstrap and Modernizr are loaded
// Declare variables we'll be using
var
result_element,
a, b, c,
root_part, denom,
root1, root2;
// Find point in DOM where result will be appended as HTML
result_element = $('#result');
// Get the coefficients of the equation from the user
a = prompt("What is the value of 'a'? \n", "1");
b = prompt("What is the value of 'b'? \n", "3");
c = prompt("What is the value of 'c'? \n", "2");
// Compute the square root and denominator of the result
root_part = Math.sqrt(b * b - 4.0 * a * c);
denom = 2.0 * a;
// Compute and display the two roots
root1 = (-b + root_part) / denom;
root2 = (-b - root_part) / denom;
console.log("Roots are: " root1 + " and " + root2);
// Display results in page
result_element.append("<p>The first root is: " + root1 + "<br />");
.append("The second root is: " + root2 + "</p>");
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>JavaScript Playground</title>
<meta name="viewport" content="width=device-width">
</head>
<body>
<div class="container">
<h1>JavaScript sandpit</h1>
<p>Play with JavaScript!</p>
<p id="result">Results will follow this element when you append to <code>$('#results')</code>.</p>
<hr>
<footer>
<p>© Swansea University 2013</p>
</footer>
</div>
<!-- /container -->
</body>
</html>
// Add custom CSS here. Bootstrap and Bootstrap Responsive are already loaded.
External resources loaded into this fiddle: