Home
<!DOCTYPE html> <html> <body> <h1>Demo: Arithmetic Operation on Number and String in JavaScript</h1> <p id="p1">5 * "4" = </p> <p id="p2">5 / "4" = </p> <p id="p3">5 % "4" = </p> <script> var num = 5, str = "4"; // string variables var multiplication = num * str; //will be 20 var division = num / str; //will be 20 var modulus = num % str; //will be 20 document.getElementById("p1").textContent += multiplication; document.getElementById("p2").textContent += division; document.getElementById("p3").textContent += modulus; </script> </body> </html>
Result: