multiplication javascript code example

Example 1: javascript 1 + "1"

console.log(10+"1"); //101
console.log(10-"1"); //9

Example 2: javascript how to multiply numbers

<!-- Multiplying two numbers in HTML and Javascript -->

<main>
<label for="firstNum">Number 1:</label>
<input type="number" id="firstNum" name="firstNum">

<label for="secondNum">Number 2:</label>
<input type="number" id="secondNum" name="secondNum"></br></br>

<button onclick="multiply()">Multiply</button></br></br>

<label for="result">Result</label>
<input type="number" id="result" name="result"/>
</main>

<script>
function multiply(){
	num1 = document.getElementById("firstNum").value;
	num2 = document.getElementById("secondNum").value;
	result = num1 * num2;
	document.getElementById("result").value = result;
}
</script>

Example 3: matrix multiplication javascrpt

function multiplyMatrix(matrixA, matrixB)
{
    var result = new Array();//declare an array   

    //var numColsRows=$("#matrixRC").val();
    numColsRows=2;
    
    //iterating through first matrix rows
    for (var i = 0; i < numColsRows; i++) 
    {
        //iterating through second matrix columns
        for (var j = 0; j < numColsRows; j++) 
        { 
            var matrixRow = new Array();//declare an array
            var rrr = new Array();
            var resu = new Array();
            //calculating sum of pairwise products
            for (var k = 0; k < numColsRows; k++) 
            {
                rrr.push(parseInt(matrixA[i][k])*parseInt(matrixB[k][j]));
            }//for 3
            resu.push(parseInt(rrr[i])+parseInt(rrr[i+1]));

            result.push(resu);
            //result.push(matrixRow);
        }//for 2
    }//for 1
    return result;
}// function multiplyMatrix

Example 4: how to do multiplication in javascript

//To multiply in Java script, you have to put an asterisk symbol '*' between them. If you have stored two numbers in variables, just put an asterisk symbol between the variable names.
//For example:
var a = 5
var b = 6
var c = a*b
var d = 5*6

Bot.send (c)/ print (c)// or whatever you use to get output
Bot.send (d)/ print (d)// or whatever you use to get output

//output will be: 30, 30

Example 5: javascript multiplication table

let table = document.createElement("table");
    for (i = 0; i < 10; i++) {
        let tr = document.createElement("tr");
        for (j = 0; j < 10; j++) {
            let td = document.createElement('td');
            td.innerHTML = (j + 1) * (i + 1);
            // td.innerHTML += (i * j) + ' '; same output if i/j = 1 & i/j < 11
            tr.appendChild(td);
        }
        table.appendChild(tr);
    }
    target.appendChild(table);