Learn HTML,CSS, Python etc from the foundation

Tuesday, January 14, 2020

FREE JAVASCRIPT LESSON 9

No comments :

Hi friends, I’m undoubted you are doing great. I’m glad you made your way to this lesson. Today, I will be teaching you another interesting topic known as Concatenation.  
Concatenation in JavaScript


By the end of this lesson, you will agree with me that the most useful operator primarily for strings is no other thing but concatenation.  At this point, you may be wondering what the heck is concatenation. Well that is what I’m about to discuss with you in this lesson. So calm down, pour yourself a cup of coffee and relax. I promise to take you by hand and work you through all you need to know about this subject matter without confusion or any form of difficulty.

To start with, concatenation simply means joining strings of text together. Put differently, concatenation is the act of building up strings by joining multiple strings together. So, the verb “concatenate” means to join together two or more strings.   Concatenation is represented by the + sign. (NB: Don’t mistake this to plus sign).


Example
To get this more clearer, open your text editor on your smartphone or computer, and enter the following codes:

<!DOCTYPE html>
<html>
<head>
            <title></title>
</head>
<body>

<script>
var firstString = "I am learning ";
var secondString = "JavaScript with Codinglegit!";
document.write(firstString + secondString);
</script>

</body>
</html> 


Save it with .html extension and then open it to see an amazing result that will display on your screen

Note The following carefully
The things you should take note of are those things in between the two script tags. First is the declaration of the two variables (i.e firstString and secondString). 

Secondly, the two string variables were assigned a value each  (i.e  “I am learning " and
“JavaScript with Codinglegit!")

And finally, we concatenates them (or joins them together using this the plus sign + .
 Also, remember that whenever you put something for example, numbers in quotation mark (“  “), JavasScript will treat that number as a string and not as a number.

We will be treating a more interesting topic in our next lesson. 

No comments :

Post a Comment