Horje Website
Creating Multi-line Strings in Older Versions of JavaScript – JavaScript Code

Creating Multi-line Strings in Older Versions of JavaScript

Creating Multi-line Strings in Older Versions of JavaScript - JavaScript Code


 
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Creating Multi-line Strings in Older Versions of JavaScript</title>
  6. </head>
  7. <body>
  8. <script>
  9. // Multi-line string
  10. var str = 'The quick brown fox\n\t'
  11. + 'jumps over the lazy dog.';
  12. document.write("<pre>" + str + "</pre>");
  13. // Creating string using variables and expression
  14. var a = 10;
  15. var b = 20;
  16. var result = 'The sum of ' + a + ' and ' + b + ' is ' + (a+b) + '.';
  17. document.write(result); // The sum of 10 and 20 is 30.
  18. </script>
  19. </body>
  20. </html>



Try Your Self ->



Published:
September 12, 2020
Author:
admin
Category:
JavaScript Example, Javascript Source Code
Views:
16

This article was posted in JavaScript Example, Javascript Source Code and tagged , , . Bookmark the permalink. Follow comments with the RSS feed for this post.Post a Comment or leave a trackback: Trackback URL.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

Horje © 2011 - 2023