"use strict"; //Licensed under the Apache License 2.0. See license file for information. function calculate() { var blocks = 0 var tenblocks = 0 var twentyfifth = 0 var embassies = 0 var capital = 0 var percent = 0 var numReg = /^\d+$/; //Get input var blocks = document.getElementById("blocks").value; var one = document.getElementById("one").value; var gov = document.getElementById("gov").value; var design = document.getElementById("design").value; var embassies = document.getElementById("embassies").value; var capital = document.getElementById("capital").value; var infra = document.getElementById("infra").value; var town = document.getElementById("town").value; var city = document.getElementById("city").value; var metro = document.getElementById("metro").value; if (blocks.match(numReg)) { //Do nothing. } else { //Tells them to enter only numbers. alert("Please enter only numbers in this field."); } var emeralds = +blocks / 1000 console.log(emeralds) var infra = +infra / 1000 * 0.005 console.log(infra) var one = +one / 1000 * 0.01 console.log(one) var design = +design / 1000 * 0.015 console.log(design) var gov = +gov / 1000 * 0.02 console.log(gov) var embassies = +embassies * 0.01 console.log(embassies) var capital = +capital * 0.025 console.log(capital) var town = +town * 0.005 console.log(town) var city = +city * 0.01 console.log(city) var metro = +metro * 0.01 console.log(metro) var percent = +one + +design + +gov + +embassies + +capital + +infra + +town + +city + +metro //var percent = +percent / 100 console.log(percent) var total = +emeralds * +percent + +emeralds var total = total.toFixed(4); console.log(total) var date = Date(); console.log(date) //Show result alert("Your secret message is " + total); document.getElementById("Answer").innerHTML = "Your secret message is " + total; }