multiplication in javascript code example

Example 1: jquery get version

jQuery().jquery;

Example 2: javascript 1 + "1"

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

Example 3: 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 4: 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);

Tags:

Php Example