Home
<!DOCTYPE html> <html> <body> <h1>Demo: Addition on Number and String in JavaScript</h1> <p id="p1">5 + "4" = </p> <p id="p2">"Five" + "Four" = </p> <script> var num = 5, str = "4"; // string variables document.getElementById("p1").textContent += num + str; document.getElementById("p2").textContent += "Five" + "Four"; </script> </body> </html>
Result: