Home
<!DOCTYPE html> <html> <body> <h1>Demo: Arithmetic Operation on Numeric Strings in JavaScript</h1> <p id="p1">"5" * "4" = </p> <p id="p2">"5" / "4" = </p> <p id="p3">"5" % "4" = </p> <script> var numStr1 = "5", numStr2 = "4"; // string variables var multiplication = numStr1 * numStr2; //will be 20 var division = numStr1 / numStr2; //will be 20 var modulus = numStr1 % numStr2; //will be 20 document.getElementById("p1").textContent += multiplication; document.getElementById("p2").textContent += division; document.getElementById("p3").textContent += modulus; document.getElementById("p4").textContent += f3; document.getElementById("p5").textContent += f3; document.getElementById("p6").textContent += f3; </script> </body> </html>
Result: