Javascript on string
Tags: javascript, beginners, tutorial, codenewbie
Published: 2023-06-14 08:42:36

Diary of a tech Lady.(Abahicana)
Javascript on string

I drafted all my strings in my javascript, created a variable, and created my usual console.Log to be sure my code was reading well. I viewed my console, and I kept on getting the incorrect code. Javascript is like that jealous girlfriend that pays attention to everything and hardly forgives an error. Should I say Javascript was me, and I was Javascript? All the times I had been a girlfriend, I was always very jealous, and I paid a lot of attention to my man because I felt that was the only way to show him all the love in me and give him the right result. More like writing the code well and following all the syntax rules. 
You won’t have anything to worry about in Javascript. Javascript demands perfection from you, and if you don’t like following all the rules, don’t come close to Javascript. 

Here was my code
script>
      const hour = 8;
      const name = ‘Tech Lady';
      if (hour >= 6 && hour <= 12) {
        console. log(‘Good morning ${name}!’ );
    </script>



When I checked my console, I kept on getting.
Good morning ${name}! Instead of Good morning Tech Lady!
Yeah, I like the name Tech Lady even though I am still in the baby phase of tech; I just learned a few things about CSS and HTML, and I am learning Javascript to make my website more interactive, but it has not been easy. 
I don’t think you should blame me for this, I come from an Art background with no rules, and you don’t have to follow the regulations verbatim to get a result. But I have had enough of Art, so I switched to tech. So everything was new to me. It’s like moving from speaking English all your life to migrating to a Russian country where nobody speaks English. At this point, you will need saving to cope.

So I returned to the tutorial video and was still not getting my codes right. What could be the issue? I even went back to compare the principles with the example code, but everything looked perfect. Then I looked at my note, and something was off. Sometimes when learning tech, you should take notes; even if it is not everything, pen down some highlighted points because it’s not every time you will remember everything or have the patience to go back to the tutorial video and get the precise information you are sourcing for.

I went back to my note and saw what I wrote about strings; I wrote that “There are three ways to write a string in Javascript; they can be written inside single quotes (‘ ‘), double quotes (“ “), and a baltic ().
Writing Strings using double quotes and single quotes is effectively the same. Still, strings created with baltic are called template strings, and they have a unique feature called interpolation which lets us insert a value directly into a string and create multiline strings.
That was when it dawned on me that my code should use Baltic ( ` ) and not the single quotes ( ‘ ) that I used. I hope you see where the issue is. This baltic dude and single-quote dudes look so much alike, yet they mean different things and are used for various reasons in Javascript. I gave Javascript a very long hissing because I refuse to be afraid of its perfectionist attitude. I am sure if Javascript was a human, it would be single, and nobody would have to be willing to be in a relationship with Javascript.

So forgive my manners. I know I said earlier that Javascript is me, and I behave like Javascript in a relationship; It was a joke, too; there is no way I can be demanding so much perfection in a relationship and expect to be courted by a man. But then the book of Songs of Solomon says, “For love is as strong as death”, and it’s even believed that when there is love, all things are possible.
So if you love being a tech person, you will have to deal with Javascript, and with js, all web development interactions are possible.
So here is how my code was supposed to look like

<script>
      const hour = 8;
      const name = ‘Tech Lady';
      if (hour >= 6 && hour <= 12) {
        console. log(`Good morning ${name}!` );
    </script>


And I will get my gracious greetings(result). Good morning Tech Lady!
Thank you for reading
Written by
Jehosheba Abahi
(D tech Lady )