Solar Panel Estimate
function sunHours(){ let hrs; let theZone = document.forms.solarForm.zone.selectedIndex; theZone +=1; switch(theZone) { case 1: hrs = 6; break; case 2: hrs = 5.5; case 3: hrs = 5; break; case 4: hrs = 4.5; break; case 5: hrs = 4.2; break; case 6: hrs = 3.5; break; default: hrs = 0; } return hrs; }
function dailyKwh(){ let monthlyUse = document.getElementById('kwhIn').value; return monthlyUse * 12/365; }
function calculatePanel(){ let userChoice = document.getElementById('panelIn').selectedIndex; let panelOptions = document.getElementById('panelIn').options; let power = panelOptions[userChoice].value; let name = panelOptions[userChoice].text; let x = [power, name] return x; }
function calculateSolar(){ let dailyUseKw = dailyKwh(); let sunHoursPerDay = sunHours(); let minKwNeeds = dailyUseKw/sunHoursPerDay; let realKwNeeds = minKwNeeds * 1.25; let realWattNeeds = realKwNeeds * 1000; let panelInfo = calculatePanel(); let panelOutput = panelInfo[0]; let panelName = panelInfo[1]; let panelsNeeded = Math.ceil(realWattNeeds/panelOutput); document.getElementById('solarRecommendation').innerHTML = feedback;}

Pick a zone, estimate your monthly KWh usage, and select your choice of solar panel.

Carpet Calculator
function floor(diameter){ let radius = diameter/2; let floorArea = Math.PI * (radius * radius); return floorArea + " Square Foot"; }

Calculate how many Sq Ft of carpet needed for a circular room.

Paint the Walls
function walls(height){ let radius = document.getElementById('carpetIn').value/2; let circumference = 2 * Math.PI * radius; let wallArea = circumference * height; return wallArea; }

Paint the walls of a circular room, don't forget to measure the floor first in the previous algorithm.

Pig Latin Translator
function translatePigLatin(str) { var pigLatin = ''; var regex = /[aeiou]/gi; if (str[0].match(regex)) { pigLatin = str + 'way'; } else if(str.match(regex) === null) { pigLatin = str + 'ay'; } else { var vowelIndice = str.indexOf(str.match(regex)[0]); pigLatin = str.substr(vowelIndice) + str.substr(0, vowelIndice) + 'ay'; } return pigLatin; }

Translates a word into Pig Latin!

String Reverser
function reverseString(str) {let array = [...str]; let backwardsArray = array.reverse(); let result = backwardsArray.toString().replace(/,/g, ''); return result; };

Submit a string of letters and words to have it reversed!

Missing Letter!
function fearNotLetter(str) { let alphabet = "abcdefghijklmnopqrstuvwxyz", chunk = alphabet.slice(alphabet.indexOf(str[0]), alphabet.indexOf(str[0]) + str.length + 1); for (let l of chunk){ if (!str.includes(l)){ return l; } } };

Finds the first missing letter in a alphabetical series! (try abcdefghjk or lmnpqrs!)

Spinalcase
function spinalCase(str) { return str.split(/\s|_|(?=[A-Z])/).join('-').toLowerCase() }

Converts a string to Spinal Case (all lowercase words joined by dashes)

To Uppercase
function titleCase(str) { return str.toLowerCase().replace(/(^|\s)\S/g, (L) => L.toUpperCase()); };

Makes the first letter of each word in a string uppercase.

Factorialize
function factorialize(num) { let posIntegers = []; if (num == 0){ return 1}; while (num > 0){ posIntegers.push(num); num--; } return posIntegers.reduce( (a,b) => a * b ); };

Multiplies a number by each number that preceeds it:

DNA Matcher
function pairElement(str) { str = str.toUpperCase(); const pairs = { "A": "T", "T": "A", "C": "G", "G": "C" } let arr = str.split(""); return arr.map(x => [x,pairs[x]]); }; };

Returns a DNA pair based on input (cytosine [C], guanine [G], adenine [A] or thymine [T])

Celcius Temperature Converter
function convertToF(celsius) { let fahrenheit = (celsius * 9/5) + 32 ; return fahrenheit; };

Enter a temperature in Celcius to convert to Fahrenheit: