Web page that calculates results of four arithmetic operations for two numbers This is the code that I have written for a simple mathematical application using javascript. In accordance with the task, I broke the program into functions that perform the computations.
But I guess my code looks very large:



function addTwoN(a, b){
    return (a + b);
}
function subtractNumb(a,b){
    return (a - b);
}
function multiplNumb(a,b){
    return (a * b);
}
function divisNumb(a,b){
    return (a / b);
}
function myFunction(){
    const firstInput = document.getElementById("first-number").value;
    const secondInput = document.getElementById("second-number").value;
    const result = document.getElementById("result");
    var firstNumb = Number(firstInput);
    var secondNumb = Number(secondInput);
    var sum = addTwoN(firstNumb, secondNumb);
    var sbtr = subtractNumb(firstNumb, secondNumb);
    var multi = multiplNumb(firstNumb, secondNumb);
    var divis = divisNumb(firstNumb, secondNumb); 
    var str = 
    firstNumb + " + " + secondNumb + " = " + sum + "&lt;br&gt;" +
    firstNumb + " - " + secondNumb + " = " + sbtr + "&lt;br&gt;" +
    firstNumb + " * " + secondNumb + " = " + multi + "&lt;br&gt;" +
    firstNumb + " / " + secondNumb + " = " + divis; 
    result.innerHTML = str;
}
&lt;link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet"&gt;
&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"&gt;
&lt;body&gt;
&lt;form class="ml-5 mb-5 mt-5"&gt;
    &lt;div class="form-group"&gt;
     &lt;label&gt;What is the first number?&lt;/label&gt;
     &lt;input type="number" class="form-control" name="" id="first-number" oninput="validity.valid||(value=''); myFunction()" min="0" style="width: 90px"&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
     &lt;label&gt;What is the second number?&lt;/label&gt;
     &lt;input type="number" class="form-control" name="" oninput="validity.valid||(value=''); myFunction()" id="second-number" min="0" style="width: 90px"&gt;
    &lt;/div&gt;
&lt;/form&gt;
&lt;div class="ml-5" id="result"&gt;&lt;/div&gt;
&lt;/body&gt;
One obvious simple change is to avoid making unnecessary variable assignments.  For example, just write

const a = Number(document.getElementById("first-number").value);


instead of


const firstInput = document.getElementById("first-number").value;
…
var firstNumb = Number(firstInput);



You should also be more consistent with naming (e.g. addTwoN vs. multiplNumb).  myFunction needs a better name; I suggest onInputUpdated.

The code could be simplified by treating each of the four operations as data.  Then, you apply the same transformation on each element of the operations list.



const operations = [
    {symbol: '+', callback: function(a, b) { return a + b }},
    {symbol: '-', callback: function(a, b) { return a - b }},
    {symbol: '*', callback: function(a, b) { return a * b }},
    {symbol: '/', callback: function(a, b) { return a / b }},
];

function onInputUpdated() {
    const a = Number(document.getElementById("first-number").value);
    const b = Number(document.getElementById("second-number").value);
    const result = operations.map(function(op) {
        return a + " " + op.symbol + " " + b + " = " + op.callback(a, b);
    }).join('&lt;br&gt;');
    document.getElementById("result").innerHTML = result;
}
&lt;link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700" rel="stylesheet"&gt;
&lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous"&gt;
&lt;body&gt;
&lt;form class="ml-5 mb-5 mt-5"&gt;
    &lt;div class="form-group"&gt;
     &lt;label&gt;What is the first number?&lt;/label&gt;
     &lt;input type="number" class="form-control" name="" id="first-number" oninput="validity.valid||(value=''); onInputUpdated()" min="0" style="width: 90px"&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
     &lt;label&gt;What is the second number?&lt;/label&gt;
     &lt;input type="number" class="form-control" name="" oninput="validity.valid||(value=''); onInputUpdated()" id="second-number" min="0" style="width: 90px"&gt;
    &lt;/div&gt;
&lt;/form&gt;
&lt;div class="ml-5" id="result"&gt;&lt;/div&gt;
&lt;/body&gt;