JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.

Any URL's added here will be added as `<script>`

s in order, and run *before* the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

` ````
<body>
<div id= "header">
<h1> Factoring Trinomials Practice </h1>
</div>
<div class = "box" id = "QuestionBox">
</div>
<button onClick = "bothForms()" > Get Question </button>
<div class = "box" id = "AnswerBox">
</div>
<button onClick = "getAnswer()"> Reveal Answer </button>
</body>
```

` ````
#header{
background: #2db22d;
padding: 1px;
border: 3px solid #005300;
border-radius: 5px;
}
body{
font-family: 'Josefin Slab', serif;
}
h1{
font-family: 'Raleway', sans-serif;
text-align: center;
color: #fff;
text-shadow: 3px 3px #000;
}
.box{
height: 50px;
width: 80%;
border: 3px solid #005e00;
border-radius: 5px;
text-align: left;
font-size: 24px;
margin-left: auto;
margin-right: auto;
margin-top: 15px;
padding: 15px;
}
button {
background: #ff8d8d;
padding: 5px;
border-radius: 5px;
}
@media only screen and (min-width: 768px){
h1{
font-size: 48px;}
}
.box{
font-size: 32px;
text-align: center;
}
```

` ````
var answer = 'Click "Get Question"';
var trinomial = {"a": "", "b": "", "c": ""};
var factorOut = 1;
/* Check if a number has a given factor */
function isFactor(num, fact){
if(num % fact == 0){
return true;
}
else{
return false;
}
}
/* List the factors of a number. */
function listFactors(number){
factors = [1];
var i = 2;
while(i <= number){
if(isFactor(number, i)){
factors.unshift(i);
}
i++;
}
return factors;
}
/* Find the GCF (greatest common factor) of a list of numbers. */
function GCF(intList){
var GCF = 1;
var factorsOfEach = [];
for(item in intList){
var num = intList[item];
var factors = listFactors(num);
factorsOfEach.push(factors);
}
var count = 0;
factorsOfFirst = factorsOfEach[0];
var length = factorsOfFirst.length;
while(count < length){
var toTest = factorsOfFirst[count];
var passTest = factorsOfEach.every(arrayContains);
if(passTest){
GCF = toTest;
return GCF;
}
else{
count += 1;
}
}
return GCF
}
var toTest = 1;
/*Check whether an array contains "toTest" */
function arrayContains(array){
if(array.indexOf(toTest) != -1){
return true}
else{
return false}
}
/* Decide whether to make a number negative. */
function makeNegative() {
var k = Math.random();
if (k >= 0.5) {
return false; // positive
} else {
return true; // negative
}
}
/* Pick two random positive or negative numbers to be the coefficient and the constant in one factor */
function getBinomial() {
var coefficient = Math.floor(2 * Math.random() + 1); //Random whole number from 1 to 3
if(makeNegative()){
coefficient *= -1;
}
var constant = Math.floor(9 * Math.random() + 1); //Random whole number from 1 to 10
if(makeNegative()){
constant *= -1;
}
if (coefficient < 0){ //If the coefficient is negative, factour out -1
factorOut *= -1;
constant /= -1;
coefficient /= -1;
}
var both = [coefficient, constant];
if(GCF(both) > 1){
factorOut *= GCF(both);
both[0] /= GCF(both);
both[1] /= GCF(both);
}
return both;
}
/* Display a binomial factor as a string */
function displayFactor(factor) {
if(factor[0] != 1){
return "(" + factor[0] + "x + " + factor[1] + ")"
}
else{
return "(x + " + factor[1] + ")"
}
}
/* Multiply the two binomials and return the product as a string */
function expand(factor1, factor2) {
trinomial.a = factor1[0] * factor2[0] * factorOut;
trinomial.b = factorOut * (factor1[0] * factor2[1] + factor1[1] * factor2[0]);
trinomial.c = factorOut * (factor1[1] * factor2[1]);
var firstTerm = "";
var secondTerm = "";
var thirdTerm = "";
if(trinomial.a == 1){
firstTerm = "x" + "2".sup() + " + "}
else{
firstTerm = trinomial.a + "x" + "2".sup() + " + ";
}
if(trinomial.b != 0){
secondTerm = trinomial.b + "x + ";
}
thirdTerm = trinomial.c;
return firstTerm + secondTerm + thirdTerm;
}
/* Create 2 binomial factors and find their expanded form. Display the expanded form as the question.*/
function bothForms() {
factorOut = 1;
answer = "";
var firstFactor = getBinomial();
var secondFactor = getBinomial();
var afterDistr = expand(firstFactor, secondFactor);
if(factorOut != 1){
answer += factorOut}
answer += displayFactor(firstFactor) + displayFactor(secondFactor);
$("#QuestionBox").html(afterDistr);
$("#AnswerBox").html("");
}
/* Display the factored form of the quadratic as the answer */
function getAnswer() {
$("#AnswerBox").html(answer);
}
```

999px

Shift F
Opt F
Find & Replace

Also see: Tab Triggers