figbertmath

[RADIOACTIVE] miscellaneous math programs in website form
git clone git://git.figbert.com/figbertmath.git
Log | Files | Refs | README

commit 473af4977ed2bad86cd1a3a3db891372917be592
parent 6185df8d584f64531665d22f7840c06918063bf7
Author: therealFIGBERT <figbertwelner@gmail.com>
Date:   Sun, 10 Nov 2019 13:05:31 -0800

Simplifying the consecutive number solver, camelcasing the CSS, and updating the Javascript syntax

Diffstat:
M.gitignore | 2++
Mangular-distance-real-size-solver/index.html | 10+++++-----
Mangular-distance-real-size-solver/sizecalc.js | 10+++++-----
Mconsecutive-number-solver/consecutiveNum.js | 223+++++++++++++++++--------------------------------------------------------------
Mconsecutive-number-solver/index.html | 8++++----
Mindex.html | 4++--
Mmain.css | 16++++++++--------
Mmatrix-solver/index.html | 44++++++++++++++++++++++----------------------
Mmatrix-solver/matrix.js | 258++++++++++++++++++++++++++++++++++++++++----------------------------------------
Mpolygon-angle-solver/index.html | 6+++---
Mpolygon-angle-solver/polycalc.js | 16++++++++--------
11 files changed, 235 insertions(+), 362 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1 +1,2 @@ .DS_Store +.idea +\ No newline at end of file diff --git a/angular-distance-real-size-solver/index.html b/angular-distance-real-size-solver/index.html @@ -9,8 +9,8 @@ </head> <body> <header> - <h1 class="pagetitle">Size Calculator</h1> - <h2 class="pagetitle pagetitle__sub">by FIGBERT</h2> + <h1 class="pageTitle">Size Calculator</h1> + <h2 class="pageTitle pageTitle__sub">by FIGBERT</h2> </header> <main> <form> @@ -25,15 +25,15 @@ <legend>Input values</legend> <div class="ins D d"> <label for="angVal">𝛼 = </label> - <input id="angVal" type="number" name="inVal" step="0.1" class="numinput numinput--large"><br> + <input id="angVal" type="number" name="inVal" step="0.1" class="numInput numInput--large"><br> </div> <div class="ins a d"> <label for="sizeVal">D = </label> - <input id="sizeVal" type="number" name="inVal" step="0.1" class="numinput numinput--large"><br> + <input id="sizeVal" type="number" name="inVal" step="0.1" class="numInput numInput--large"><br> </div> <div class="ins a D"> <label for="distVal">d = </label> - <input id="distVal" type="number" name="inVal" step="0.1" class="numinput numinput--large"><br> + <input id="distVal" type="number" name="inVal" step="0.1" class="numInput numInput--large"><br> </div> <input type="button" value="Solve" onclick="actionManager(angVal.value, sizeVal.value, distVal.value)"> </fieldset> diff --git a/angular-distance-real-size-solver/sizecalc.js b/angular-distance-real-size-solver/sizecalc.js @@ -1,22 +1,22 @@ -var type; +let type; function show(elements) { "use strict"; - for (var a = 0; a < elements.length; a++) { + for (let a = 0; a < elements.length; a++) { elements[a].style.display = "inline"; } } function hide(elements) { "use strict"; - for (var a = 0; a < elements.length; a++) { + for (let a = 0; a < elements.length; a++) { elements[a].style.display = "none"; } } function reset(elements) { "use strict"; - for (var a = 0; a < elements.length; a++) { + for (let a = 0; a < elements.length; a++) { elements[a].value = ""; } } @@ -26,7 +26,7 @@ function setUp(selection) { type = selection; document.getElementById("sizeIn").style.display = "block"; hide(document.getElementsByClassName("ins")); - reset(document.getElementsByClassName("numinput")); + reset(document.getElementsByClassName("numInput")); if (type === "a") { show(document.getElementsByClassName("a")); } else if (type === "D") { diff --git a/consecutive-number-solver/consecutiveNum.js b/consecutive-number-solver/consecutiveNum.js @@ -5,185 +5,56 @@ function getSum(total, num) { function solveConsec(amount, sum, type) { "use strict"; - var numAmount = parseInt(amount, 10), - numSum = parseInt(sum, 10), - smallestNum = 0, - allNums = []; - switch (type) { - case "odd": - if (numSum > 0) { - smallestNum = 1; - var a = 0; - for (var b = 0; b < numAmount; b++) { - allNums.push(smallestNum + a); - a += 2; - } - while ( - allNums.reduce(getSum) !== numSum && - allNums.reduce(getSum) < numSum - ) { - for (var c = 0; c < allNums.length; c++) { - allNums[c] += 2; - } - } - if (allNums.reduce(getSum) > numSum) { - document.getElementById("outText").innerHTML = - "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; - } else { - document.getElementById("outText").innerHTML = - "Success! The " + - numAmount + - " consecutive numbers that equal " + - numSum + - " are " + - allNums + - "."; - } - } else if (numSum < 0) { - smallestNum = -1; - var d = 0; - for (var e = 0; e < numAmount; e++) { - allNums.push(smallestNum + d); - d -= 2; - } - while ( - allNums.reduce(getSum) !== numSum && - allNums.reduce(getSum) > numSum - ) { - for (var f = 0; f < allNums.length; f++) { - allNums[f] -= 2; - } - } - if (allNums.reduce(getSum) > numSum) { - document.getElementById("outText").innerHTML = - "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; - } else { - document.getElementById("outText").innerHTML = - "Success! The " + - numAmount + - " consecutive numbers that equal " + - numSum + - " are " + - allNums + - "."; - } + let smallestNum, + step, + addend = 0, + numAmount = parseInt(amount, 10), + numSum = parseInt(sum, 10), + allNums = []; + if (type === "odd") { + smallestNum = ((numSum > 0) ? 1 : -1); + step = ((numSum > 0) ? 2 : -2); + } else if (type === "even") { + smallestNum = 0; + step = ((numSum > 0) ? 2 : -2); + } else if (type === "mixed") { + smallestNum = 0; + step = ((numSum > 0) ? 1 : -1); } - break; - case "even": - if (numSum > 0) { - var a = 0; - for (var b = 0; b < numAmount; b++) { - allNums.push(smallestNum + a); - a += 2; - } - while ( - allNums.reduce(getSum) !== numSum && - allNums.reduce(getSum) < numSum - ) { - for (var c = 0; c < allNums.length; c++) { - allNums[c] += 2; - } - } - if (allNums.reduce(getSum) > numSum) { - document.getElementById("outText").innerHTML = - "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; - } else { - document.getElementById("outText").innerHTML = - "Success! The " + - numAmount + - " consecutive numbers that equal " + - numSum + - " are " + - allNums + - "."; - } - } else if (numSum < 0) { - var d = 0; - for (var e = 0; e < numAmount; e++) { - allNums.push(smallestNum + d); - d -= 2; - } - while ( - allNums.reduce(getSum) !== numSum && - allNums.reduce(getSum) > numSum - ) { - for (var f = 0; f < allNums.length; f++) { - allNums[f] -= 2; - } - } - if (allNums.reduce(getSum) > numSum) { - document.getElementById("outText").innerHTML = - "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; - } else { - document.getElementById("outText").innerHTML = - "Success! The " + - numAmount + - " consecutive numbers that equal " + - numSum + - " are " + - allNums + - "."; - } + for (let a = 0; a < numAmount; a++) { + allNums.push(smallestNum + addend); + addend += step; } - break; - case "mixed": if (numSum > 0) { - for (var g = 0; g < numAmount; g++) { - allNums.push(smallestNum + g); - } - while ( - allNums.reduce(getSum) !== numSum && - allNums.reduce(getSum) < numSum - ) { - for (var h = 0; h < allNums.length; h++) { - allNums[h]++; + while ( + allNums.reduce(getSum) !== numSum && + allNums.reduce(getSum) < numSum + ) { + for (let a = 0; a < allNums.length; a++) { + allNums[a] += step; + } } - } - if (allNums.reduce(getSum) > numSum) { - document.getElementById("outText").innerHTML = - "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; - } else { - document.getElementById("outText").innerHTML = - "Success! The " + - numAmount + - " consecutive numbers that equal " + - numSum + - " are " + - allNums + - "."; - } } else if (numSum < 0) { - var i = 0; - for (var j = 0; j < numAmount; j++) { - allNums.push(smallestNum + i); - i--; - } - while ( - allNums.reduce(getSum) !== numSum && - allNums.reduce(getSum) > numSum - ) { - for (var k = 0; k < allNums.length; k++) { - allNums[k]--; + while ( + allNums.reduce(getSum) !== numSum && + allNums.reduce(getSum) > numSum + ) { + for (let a = 0; a < allNums.length; a++) { + allNums[a] += step; + } } - } - if (allNums.reduce(getSum) > numSum) { - document.getElementById("outText").innerHTML = - "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; - } else { - document.getElementById("outText").innerHTML = - "Success! The " + - numAmount + - " consecutive numbers that equal " + - numSum + - " are " + - allNums + - "."; - } } - break; - } -} -/* -Test values: -4 consequtive even integers equal 100 -*/ -\ No newline at end of file + if (allNums.reduce(getSum) > numSum || allNums.reduce(getSum) < numSum) { + document.getElementById("outText").innerHTML = + "Unfortunately, the combination entered does not have an answer. Try again with another set of values."; + } else { + document.getElementById("outText").innerHTML = + "Success! The " + + numAmount + + " consecutive numbers that equal " + + numSum + + " are " + + allNums + + "."; + } +} +\ No newline at end of file diff --git a/consecutive-number-solver/index.html b/consecutive-number-solver/index.html @@ -9,8 +9,8 @@ </head> <body> <header> - <h1 class="pagetitle">Consecutive Number Solver</h1> - <h2 class="pagetitle pagetitle__sub">by FIGBERT</h2> + <h1 class="pageTitle">Consecutive Number Solver</h1> + <h2 class="pageTitle pageTitle__sub">by FIGBERT</h2> </header> <main> <form> @@ -18,11 +18,11 @@ <legend id="bigBox">Configure the number set</legend> <fieldset> <legend>Set the amount of numbers</legend> - <label for="numSet">There are <input type="number" step="1" min="2" id="numSet" class="numinput"> numbers</label> + <label for="numSet">There are <input type="number" step="1" min="2" id="numSet" class="numInput"> numbers</label> </fieldset> <fieldset> <legend>Set the sum of the numbers</legend> - <label for="sumSet">The sum of the numbers is <input type="number" step="1" id="sumSet" class="numinput"></label> + <label for="sumSet">The sum of the numbers is <input type="number" step="1" id="sumSet" class="numInput"></label> </fieldset> <fieldset> <legend>Set the type of the numbers</legend> diff --git a/index.html b/index.html @@ -12,8 +12,8 @@ </head> <body> <header> - <h1 class="pagetitle">FIGBERT Math</h1> - <h2 class="pagetitle pagetitle__sub">Homework is for Pussies</h2> + <h1 class="pageTitle">FIGBERT Math</h1> + <h2 class="pageTitle pageTitle__sub">Homework is for Pussies</h2> </header> <table> <tr> diff --git a/main.css b/main.css @@ -1,7 +1,7 @@ body { font-family: sans-serif, monospace; background-color: #1A181C; - margin: 0px; + margin: 0; } header { @@ -10,16 +10,16 @@ header { width: 100%; } -.pagetitle { - margin: 0px; - padding: 10px 10px 0px 10px; +.pageTitle { + margin: 0; + padding: 10px 10px 0 10px; font-size: calc(28px + 0.5vw); color: #B494C7; } -.pagetitle__sub { +.pageTitle__sub { padding-bottom: 10px; - padding-top: 0px; + padding-top: 0; font-size: calc(20px + 0.25vw); } @@ -39,14 +39,14 @@ td { color: #ACA0B2; } -.numinput { +.numInput { background-color: #8E60A7; color: #ACA0B2; border-color: #ACA0B2; width: 3%; } -.numinput--large { +.numInput--large { width: 5%; } diff --git a/matrix-solver/index.html b/matrix-solver/index.html @@ -9,8 +9,8 @@ </head> <body> <header> - <h1 class="pagetitle">Simultaneous Equation Solver</h1> - <h2 class="pagetitle pagetitle__sub">by FIGBERT</h2> + <h1 class="pageTitle">Simultaneous Equation Solver</h1> + <h2 class="pageTitle pageTitle__sub">by FIGBERT</h2> </header> <main> <form> @@ -24,32 +24,32 @@ <fieldset id="equations" class="hidden"> <legend>Set the equation values</legend> <div> - <label for="wOne" class="w"><input id="wOne" type="number" name="setOne" class="numinput w a" step="0.01">w</label> - <label for="xOne"><input id="xOne" type="number" name="setOne" class="numinput a" step="0.01">x</label> - <label for="yOne"><input id="yOne" type="number" name="setOne" class="numinput a" step="0.01">y</label> - <label for="zOne" class="z"><input id="zOne" type="number" name="setOne" class="numinput z a" step="0.01">z</label> - <label for="equalsOne">=<input id="equalsOne" type="number" name="setOne" class="numinput a" step="0.01"></label> + <label for="wOne" class="w"><input id="wOne" type="number" name="setOne" class="numInput w a" step="0.01">w</label> + <label for="xOne"><input id="xOne" type="number" name="setOne" class="numInput a" step="0.01">x</label> + <label for="yOne"><input id="yOne" type="number" name="setOne" class="numInput a" step="0.01">y</label> + <label for="zOne" class="z"><input id="zOne" type="number" name="setOne" class="numInput z a" step="0.01">z</label> + <label for="equalsOne">=<input id="equalsOne" type="number" name="setOne" class="numInput a" step="0.01"></label> </div> <div> - <label for="wTwo" class="w"><input id="wTwo" type="number" name="setTwo" class="numinput w a" step="0.01">w</label> - <label for="xTwo"><input id="xTwo" type="number" name="setTwo" class="numinput a" step="0.01">x</label> - <label for="yTwo"><input id="yTwo" type="number" name="setTwo" class="numinput a" step="0.01">y</label> - <label for="zTwo" class="z"><input id="zTwo" type="number" name="setTwo" class="numinput z a" step="0.01">z</label> - <label for="equalsTwo">=<input id="equalsTwo" type="number" name="setTwo" class="numinput a" step="0.01"></label> + <label for="wTwo" class="w"><input id="wTwo" type="number" name="setTwo" class="numInput w a" step="0.01">w</label> + <label for="xTwo"><input id="xTwo" type="number" name="setTwo" class="numInput a" step="0.01">x</label> + <label for="yTwo"><input id="yTwo" type="number" name="setTwo" class="numInput a" step="0.01">y</label> + <label for="zTwo" class="z"><input id="zTwo" type="number" name="setTwo" class="numInput z a" step="0.01">z</label> + <label for="equalsTwo">=<input id="equalsTwo" type="number" name="setTwo" class="numInput a" step="0.01"></label> </div> <div id="thirdEquation"> - <label for="wThree" class="w"><input id="wThree" type="number" name="setThree" class="numinput w a" step="0.01">w</label> - <label for="xThree"><input id="xThree" type="number" name="setThree" class="numinput a" step="0.01">x</label> - <label for="yThree"><input id="yThree" type="number" name="setThree" class="numinput a" step="0.01">y</label> - <label for="zThree" class="z"><input id="zThree" type="number" name="setThree" class="numinput z a" step="0.01">z</label> - <label for="equalsThree">=<input id="equalsThree" type="number" name="setThree" class="numinput a" step="0.01"></label> + <label for="wThree" class="w"><input id="wThree" type="number" name="setThree" class="numInput w a" step="0.01">w</label> + <label for="xThree"><input id="xThree" type="number" name="setThree" class="numInput a" step="0.01">x</label> + <label for="yThree"><input id="yThree" type="number" name="setThree" class="numInput a" step="0.01">y</label> + <label for="zThree" class="z"><input id="zThree" type="number" name="setThree" class="numInput z a" step="0.01">z</label> + <label for="equalsThree">=<input id="equalsThree" type="number" name="setThree" class="numInput a" step="0.01"></label> </div> <div id="fourthEquation"> - <label for="wFour" class="w"><input id="wFour" type="number" name="setFour" class="numinput w a" step="0.01">w</label> - <label for="xFour"><input id="xFour" type="number" name="setFour" class="numinput a" step="0.01">x</label> - <label for="yFour"><input id="yFour" type="number" name="setFour" class="numinput a" step="0.01">y</label> - <label for="zFour" class="z"><input id="zFour" type="number" name="setFour" class="numinput z a" step="0.01">z</label> - <label for="equalsFour">=<input id="equalsFour" type="number" name="setFour" class="numinput a" step="0.01"></label> + <label for="wFour" class="w"><input id="wFour" type="number" name="setFour" class="numInput w a" step="0.01">w</label> + <label for="xFour"><input id="xFour" type="number" name="setFour" class="numInput a" step="0.01">x</label> + <label for="yFour"><input id="yFour" type="number" name="setFour" class="numInput a" step="0.01">y</label> + <label for="zFour" class="z"><input id="zFour" type="number" name="setFour" class="numInput z a" step="0.01">z</label> + <label for="equalsFour">=<input id="equalsFour" type="number" name="setFour" class="numInput a" step="0.01"></label> </div> <input type="button" value="Solve" onclick="solveMatrix(eqSet.value)"> </fieldset> diff --git a/matrix-solver/matrix.js b/matrix-solver/matrix.js @@ -1,17 +1,17 @@ //lcm() calculates the lowest common multiple by adding the first number until it is divisible by the second. function lcm(numOne, numTwo) { "use strict"; - var i = numOne; - while (i % numTwo !== 0) { - i += numOne; + let a = numOne; + while (a % numTwo !== 0) { + a += numOne; } - return i; + return a; } //invert() changes all of the values in a numerical array to their opposites (1 to -1, etc) with a for loop function invert(value) { "use strict"; - for (var a = 0; a < value.length; a++) { + for (let a = 0; a < value.length; a++) { value[a] = value[a] * -1; } return value; @@ -20,33 +20,33 @@ function invert(value) { //hide() hides arrayed html elements using the "display: none" method and a for loop function hide(elements) { "use strict"; - for (var b = 0; b < elements.length; b++) { - elements[b].style.display = "none"; + for (let a = 0; a < elements.length; a++) { + elements[a].style.display = "none"; } } //reset() clears html number inputs by setting their value to null function reset(elements) { "use strict"; - for (var c = 0; c < elements.length; c++) { - elements[c].value = null; + for (let a = 0; a < elements.length; a++) { + elements[a].value = null; } } //show() shows arrayed html elements INLINE using a for loop function show(elements) { "use strict"; - for (var d = 0; d < elements.length; d++) { - elements[d].style.display = "inline"; + for (let a = 0; a < elements.length; a++) { + elements[a].style.display = "inline"; } } //setUp() will determine the number of equations and variables and adjust the html accordingly. function setUpMatrix(num) { "use strict"; - var allW = document.getElementsByClassName("w"), - allZ = document.getElementsByClassName("z"), - all = document.getElementsByClassName("a"); + const allW = document.getElementsByClassName("w"), + allZ = document.getElementsByClassName("z"), + all = document.getElementsByClassName("a"); if (num === "2") { document.getElementById("equations").style.display = "block"; hide(allW); @@ -77,45 +77,45 @@ function setUpMatrix(num) { //answerTwo() accepts two simplified equations as input and outputs the x and y values function answerTwo(one, two) { "use strict"; - var y = two[2] / two[1], - x = (one[2] - one[1] * y) / one[0]; + const y = two[2] / two[1], + x = (one[2] - one[1] * y) / one[0]; return [x, y]; } //answerThree() accepts three simplified equations as input and outputs the x, y, and z values function answerThree(one, two, three) { "use strict"; - var z = three[3] / three[2], - y = (two[3] - two[2] * z) / two[1], - x = (one[3] - (one[2] * z + one[1] * y)) / one[0]; + const z = three[3] / three[2], + y = (two[3] - two[2] * z) / two[1], + x = (one[3] - (one[2] * z + one[1] * y)) / one[0]; return [x, y, z]; } //answerFour() accepts four simplified equations as input and outputs the w, x, y, and z values function answerFour(one, two, three, four) { "use strict"; - var z = four[4] / four[3], - y = (three[4] - three[3] * z) / three[2], - x = (two[4] - (two[3] * z + two[2] * y)) / two[1], - w = (one[4] - (one[3] * z + one[2] * y + one[1] * x)) / one[0]; + const z = four[4] / four[3], + y = (three[4] - three[3] * z) / three[2], + x = (two[4] - (two[3] * z + two[2] * y)) / two[1], + w = (one[4] - (one[3] * z + one[2] * y + one[1] * x)) / one[0]; return [w, x, y, z]; } //solveTwoMatrix() accepts two equations as input and simplifies the second function solveTwoMatrix(one, two) { "use strict"; - var multOne = lcm(one[0], two[0]) / one[0], - multTwo = lcm(one[0], two[0]) / two[0], - changingOne = one.slice(); - for (var e = 0; e < two.length; e++) { - changingOne[e] *= multOne; - two[e] *= multTwo; + const multOne = lcm(one[0], two[0]) / one[0], + multTwo = lcm(one[0], two[0]) / two[0], + changingOne = one.slice(); + for (let a = 0; a < two.length; a++) { + changingOne[a] *= multOne; + two[a] *= multTwo; } if (changingOne[0] + two[0] !== 0) { invert(changingOne); } - for (var f = 0; f < two.length; f++) { - two[f] += changingOne[f]; + for (let a = 0; a < two.length; a++) { + two[a] += changingOne[a]; } return two; } @@ -123,20 +123,20 @@ function solveTwoMatrix(one, two) { //solveThreeMatrix() accepts three equations as input and outputs the simplified second and third function solveThreeMatrix(one, two, three) { "use strict"; - var simpleTwo = solveTwoMatrix(one, two), - simpleThree = solveTwoMatrix(one, three), - multTwo = lcm(simpleTwo[1], simpleThree[1]) / simpleTwo[1], - multThree = lcm(simpleTwo[1], simpleThree[1]) / simpleThree[1], - changingTwo = simpleTwo.slice(); - for (var g = 0; g < simpleThree.length; g++) { - changingTwo[g] *= multTwo; - simpleThree[g] *= multThree; + const simpleTwo = solveTwoMatrix(one, two), + simpleThree = solveTwoMatrix(one, three), + multTwo = lcm(simpleTwo[1], simpleThree[1]) / simpleTwo[1], + multThree = lcm(simpleTwo[1], simpleThree[1]) / simpleThree[1], + changingTwo = simpleTwo.slice(); + for (let a = 0; a < simpleThree.length; a++) { + changingTwo[a] *= multTwo; + simpleThree[a] *= multThree; } if (changingTwo[1] + simpleThree[1] !== 0) { invert(changingTwo); } - for (var h = 0; h < simpleThree.length; h++) { - simpleThree[h] += changingTwo[h]; + for (let a = 0; a < simpleThree.length; a++) { + simpleThree[a] += changingTwo[a]; } return [simpleTwo, simpleThree]; } @@ -144,33 +144,33 @@ function solveThreeMatrix(one, two, three) { //solveFourMatrix() accepts four equations as input and outputs the simplified second, third, and fourth function solveFourMatrix(one, two, three, four) { "use strict"; - var simpleTwoThree = solveThreeMatrix(one, two, three), - simpleFour = solveTwoMatrix(one, four), - changingTwo = simpleTwoThree[0], - changingThree = simpleTwoThree[1], - multTwo = lcm(changingTwo[1], simpleFour[1]) / changingTwo[1], - firstMultFour = lcm(changingTwo[1], simpleFour[1]) / simpleFour[1]; - for (var a = 0; a < simpleFour.length; a++) { + const simpleTwoThree = solveThreeMatrix(one, two, three), + simpleFour = solveTwoMatrix(one, four), + changingTwo = simpleTwoThree[0], + changingThree = simpleTwoThree[1], + multTwo = lcm(changingTwo[1], simpleFour[1]) / changingTwo[1], + firstMultFour = lcm(changingTwo[1], simpleFour[1]) / simpleFour[1]; + for (let a = 0; a < simpleFour.length; a++) { simpleFour[a] *= firstMultFour; changingTwo[a] *= multTwo; } if (simpleFour[1] + changingTwo[1] !== 0) { invert(changingTwo); } - for (var b = 0; b < simpleFour.length; b++) { - simpleFour[b] += changingTwo[b]; + for (let a = 0; a < simpleFour.length; a++) { + simpleFour[a] += changingTwo[a]; } - var multThree = lcm(changingThree[2], simpleFour[2]) / changingThree[2], - secondMultFour = lcm(changingThree[2], simpleFour[2]) / simpleFour[2]; - for (var c = 0; c < simpleFour.length; c++) { - changingThree[c] *= multThree; - simpleFour[c] *= secondMultFour; + const multThree = lcm(changingThree[2], simpleFour[2]) / changingThree[2], + secondMultFour = lcm(changingThree[2], simpleFour[2]) / simpleFour[2]; + for (let a = 0; a < simpleFour.length; a++) { + changingThree[a] *= multThree; + simpleFour[a] *= secondMultFour; } if (simpleFour[2] + changingThree[2] !== 0) { invert(changingThree); } - for (var d = 0; d < simpleFour.length; d++) { - simpleFour[d] += changingThree[d]; + for (let a = 0; a < simpleFour.length; a++) { + simpleFour[a] += changingThree[a]; } return [simpleTwoThree[0], simpleTwoThree[1], simpleFour]; } @@ -179,18 +179,18 @@ function solveFourMatrix(one, two, three, four) { function solveMatrix(dimension) { "use strict"; if (dimension === "2") { - var firstXY = [ - parseInt(document.getElementById("xOne").value), - parseInt(document.getElementById("yOne").value), - parseInt(document.getElementById("equalsOne").value) - ], - secondXY = [ - parseInt(document.getElementById("xTwo").value), - parseInt(document.getElementById("yTwo").value), - parseInt(document.getElementById("equalsTwo").value) - ], - answerXY = solveTwoMatrix(firstXY, secondXY), - valuesXY = answerTwo(firstXY, answerXY); + const firstXY = [ + parseInt(document.getElementById("xOne").value), + parseInt(document.getElementById("yOne").value), + parseInt(document.getElementById("equalsOne").value) + ], + secondXY = [ + parseInt(document.getElementById("xTwo").value), + parseInt(document.getElementById("yTwo").value), + parseInt(document.getElementById("equalsTwo").value) + ], + answerXY = solveTwoMatrix(firstXY, secondXY), + valuesXY = answerTwo(firstXY, answerXY); show([document.getElementById("out")]); hide([ document.getElementById("titleThree"), @@ -207,26 +207,26 @@ function solveMatrix(dimension) { document.getElementById("xValue").innerHTML = "x = " + valuesXY[0]; document.getElementById("yValue").innerHTML = "y = " + valuesXY[1]; } else if (dimension === "3") { - var firstXYZ = [ - parseInt(document.getElementById("xOne").value), - parseInt(document.getElementById("yOne").value), - parseInt(document.getElementById("zOne").value), - parseInt(document.getElementById("equalsOne").value) - ], - secondXYZ = [ - parseInt(document.getElementById("xTwo").value), - parseInt(document.getElementById("yTwo").value), - parseInt(document.getElementById("zTwo").value), - parseInt(document.getElementById("equalsTwo").value) - ], - thirdXYZ = [ - parseInt(document.getElementById("xThree").value), - parseInt(document.getElementById("yThree").value), - parseInt(document.getElementById("zThree").value), - parseInt(document.getElementById("equalsThree").value) - ], - answerXYZ = solveThreeMatrix(firstXYZ, secondXYZ, thirdXYZ), - valuesXYZ = answerThree(firstXYZ, answerXYZ[0], answerXYZ[1]); + const firstXYZ = [ + parseInt(document.getElementById("xOne").value), + parseInt(document.getElementById("yOne").value), + parseInt(document.getElementById("zOne").value), + parseInt(document.getElementById("equalsOne").value) + ], + secondXYZ = [ + parseInt(document.getElementById("xTwo").value), + parseInt(document.getElementById("yTwo").value), + parseInt(document.getElementById("zTwo").value), + parseInt(document.getElementById("equalsTwo").value) + ], + thirdXYZ = [ + parseInt(document.getElementById("xThree").value), + parseInt(document.getElementById("yThree").value), + parseInt(document.getElementById("zThree").value), + parseInt(document.getElementById("equalsThree").value) + ], + answerXYZ = solveThreeMatrix(firstXYZ, secondXYZ, thirdXYZ), + valuesXYZ = answerThree(firstXYZ, answerXYZ[0], answerXYZ[1]); show([ document.getElementById("out"), document.getElementById("titleThree") @@ -271,46 +271,46 @@ function solveMatrix(dimension) { document.getElementById("yValue").innerHTML = "y = " + valuesXYZ[1]; document.getElementById("zValue").innerHTML = "z = " + valuesXYZ[2]; } else { - var firstWXYZ = [ - parseInt(document.getElementById("wOne").value), - parseInt(document.getElementById("xOne").value), - parseInt(document.getElementById("yOne").value), - parseInt(document.getElementById("zOne").value), - parseInt(document.getElementById("equalsOne").value) - ], - secondWXYZ = [ - parseInt(document.getElementById("wTwo").value), - parseInt(document.getElementById("xTwo").value), - parseInt(document.getElementById("yTwo").value), - parseInt(document.getElementById("zTwo").value), - parseInt(document.getElementById("equalsTwo").value) - ], - thirdWXYZ = [ - parseInt(document.getElementById("wThree").value), - parseInt(document.getElementById("xThree").value), - parseInt(document.getElementById("yThree").value), - parseInt(document.getElementById("zThree").value), - parseInt(document.getElementById("equalsThree").value) - ], - fourthWXYZ = [ - parseInt(document.getElementById("wFour").value), - parseInt(document.getElementById("xFour").value), - parseInt(document.getElementById("yFour").value), - parseInt(document.getElementById("zFour").value), - parseInt(document.getElementById("equalsFour").value) - ], - answerWXYZ = solveFourMatrix( - firstWXYZ, - secondWXYZ, - thirdWXYZ, - fourthWXYZ - ), - valuesWXYZ = answerFour( - firstWXYZ, - answerWXYZ[0], - answerWXYZ[1], - answerWXYZ[2] - ); + const firstWXYZ = [ + parseInt(document.getElementById("wOne").value), + parseInt(document.getElementById("xOne").value), + parseInt(document.getElementById("yOne").value), + parseInt(document.getElementById("zOne").value), + parseInt(document.getElementById("equalsOne").value) + ], + secondWXYZ = [ + parseInt(document.getElementById("wTwo").value), + parseInt(document.getElementById("xTwo").value), + parseInt(document.getElementById("yTwo").value), + parseInt(document.getElementById("zTwo").value), + parseInt(document.getElementById("equalsTwo").value) + ], + thirdWXYZ = [ + parseInt(document.getElementById("wThree").value), + parseInt(document.getElementById("xThree").value), + parseInt(document.getElementById("yThree").value), + parseInt(document.getElementById("zThree").value), + parseInt(document.getElementById("equalsThree").value) + ], + fourthWXYZ = [ + parseInt(document.getElementById("wFour").value), + parseInt(document.getElementById("xFour").value), + parseInt(document.getElementById("yFour").value), + parseInt(document.getElementById("zFour").value), + parseInt(document.getElementById("equalsFour").value) + ], + answerWXYZ = solveFourMatrix( + firstWXYZ, + secondWXYZ, + thirdWXYZ, + fourthWXYZ + ), + valuesWXYZ = answerFour( + firstWXYZ, + answerWXYZ[0], + answerWXYZ[1], + answerWXYZ[2] + ); show([document.getElementById("out")]); document.getElementById("outOne").innerHTML = "[" + diff --git a/polygon-angle-solver/index.html b/polygon-angle-solver/index.html @@ -9,8 +9,8 @@ </head> <body> <header> - <h1 class="pagetitle">Polygon Angle Calculator</h1> - <h2 class="pagetitle pagetitle__sub">by FIGBERT</h2> + <h1 class="pageTitle">Polygon Angle Calculator</h1> + <h2 class="pageTitle pageTitle__sub">by FIGBERT</h2> </header> <main> <form> @@ -18,7 +18,7 @@ <legend>Configure the polygon</legend> <label for="regular"><input id="regular" type="radio" name="typeSelect" value="0">Regular</label><br> <label for="irregular"><input id="irregular" type="radio" name="typeSelect" value="1">Irregular CONVEX</label><br> - <label for="sides">Sides: <input id="sides" type="number" step="1" min="3" class="numinput numinput--large"></label><br> + <label for="sides">Sides: <input id="sides" type="number" step="1" min="3" class="numInput numInput--large"></label><br> <input type="button" value="Go" onclick="actionManager(typeSelect.value, sides.value)"> </fieldset> </form> diff --git a/polygon-angle-solver/polycalc.js b/polygon-angle-solver/polycalc.js @@ -1,7 +1,7 @@ function errors(type, sides) { "use strict"; - var msg = "", - yes = false; + let msg = "", + yes = false; console.log(type); if (type !== "0" && type !== "1") { msg += "A type is required! Please select one and try again."; @@ -20,18 +20,18 @@ function errors(type, sides) { function actionManager(type, sides) { "use strict"; sides = Math.round(sides); - var errorTest = errors(type, sides), - msg = "Oops! Something broke.", - rounded = ""; + let errorTest = errors(type, sides), + msg = "Oops! Something broke.", + rounded = ""; if (errorTest[0]) { msg = errorTest[1]; } else { type = Number(type); sides = Number(sides); - var totalInterior = (sides - 2) * 180; + const totalInterior = (sides - 2) * 180; if (type === 0) { - var eachInterior = totalInterior / sides, - eachExterior = 360 / sides; + let eachInterior = totalInterior / sides, + eachExterior = 360 / sides; if (eachInterior % 1 !== 0) { eachInterior = Math.round(eachInterior); rounded = "~";