How two add to string:- JavaScript

  • The strings should be in double or single quotes.
  • The plus (+) operator is used to add two strings.
        

JavaScript code:-




<!DOCTYPE html> 
<html> 
<head> 
 <meta name="viewport" content="width=device-width, initial-scale=1"> 
</head> 
<body> 
 <h1>Add Two String</h1> 
 <div id="str"></div> 
 <input type="button" onclick="cal_str();" value="Add Two String"> 
 <script> 
  function cal_str() 
  { 
   document.getElementById('str').innerText = "Text1 " + "and" + " Text 2"; 
  } 
 </script> 
</body> 
</html>

How two add to string:- JavaScript How two add to string:- JavaScript Reviewed by Network security on June 01, 2019 Rating: 5

No comments:

Useful Information

Powered by Blogger.