multiplication javascript code example
Example 1: javascript 1 + "1"
console.log(10+"1");
console.log(10-"1");
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();
numColsRows=2;
for (var i = 0; i < numColsRows; i++)
{
for (var j = 0; j < numColsRows; j++)
{
var matrixRow = new Array();
var rrr = new Array();
var resu = new Array();
for (var k = 0; k < numColsRows; k++)
{
rrr.push(parseInt(matrixA[i][k])*parseInt(matrixB[k][j]));
}
resu.push(parseInt(rrr[i])+parseInt(rrr[i+1]));
result.push(resu);
}
}
return result;
}
Example 4: how to do multiplication in javascript
var a = 5
var b = 6
var c = a*b
var d = 5*6
Bot.send (c)/ print (c)
Bot.send (d)/ print (d)
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);
tr.appendChild(td);
}
table.appendChild(tr);
}
target.appendChild(table);