Ad

Mines better.

Code
Diff
  • function calculator(num1, num2, operationString) {
      if (operationString == "-") {
        return num1 - num2;
      }
      if (operationString == "+") {
        return num1 + num2;
      }
      if (operationString == "*") {
        return num1 * num2;
      }
      if (operationString == "/") {
        return num1 / num2;
      }
    }
    calculator(1, 2, "+");
    • // The operation with the number "1" goes first
    • var add1 = 0
    • var add2 = 0
    • var minus1 = 0
    • var minus2 = 0
    • var divide1 = 0
    • var divide2 = 0
    • var times1 = 0
    • var times2 = 0
    • //change the numbers in the varibles above
    • console.log("Addition" , add1 + add2) //Addition
    • console.log("Subtraction", minus1-minus2) //Subtraction
    • console.log("Division" , divide1/divide2) //Division
    • console.log("Multiplication" , times1*times2) //Multiplication
    • function calculator(num1, num2, operationString) {
    • if (operationString == "-") {
    • return num1 - num2;
    • }
    • if (operationString == "+") {
    • return num1 + num2;
    • }
    • if (operationString == "*") {
    • return num1 * num2;
    • }
    • if (operationString == "/") {
    • return num1 / num2;
    • }
    • }
    • calculator(1, 2, "+");

Make a file get downloaded.

function download(filename, text) {
          var element = document.createElement("a");
          element.setAttribute(
            "href",
            "data:text/plain;charset=utf-8," + encodeURIComponent(text)
          );
          element.setAttribute("download", filename);

          element.style.display = "none";
          document.body.appendChild(element);

          element.click();

          document.body.removeChild(element);
        }

        window.onload = function() {
            var text = "downloaded file";
            var filenames = "file";
            var filename = filenames + ".txt";

            download(filename, text);
        }