Blog 3 : JavaScript Essentials for Beginners

Blog 3 : JavaScript Essentials for Beginners

ยท

3 min read

Hello, fellow coders! Welcome back to the latest installment of "Priyanshu Mishra Blogs"!

Today, we're diving into Part-3 of our JavaScript for Beginners series, and I can't wait to see your programming skills continue to grow. ๐Ÿš€

Just to jog your memory, in Part-1, we delved into the world of JavaScript with topics like Printing Statements, Variables, and Arithmetic Operators. It was a foundational step that set the stage for your coding journey.

And who can forget Part-2? We explored Incrementing and Decrementing numbers, handy Shortcuts (*=, /=), adding 1 to numbers, and even cracked the code on Escape sequences in strings (๐ŸŽƒ).

If you haven't had the chance to check out Part-1 and Part-2, I highly recommend doing so. These articles lay the groundwork for what we're about to explore in this edition. ๐Ÿ˜‰

Now, let's get ready to level up your JavaScript skills! ๐Ÿ’ป๐Ÿ”ฅ

Topic:๐Ÿ‘‡

Concatenating strings with plus operator ๐ŸŽ“

EXAMPLE:

var mystr = "Hi I am Rachit, " + " How are you?"
console.log(mystr)

OUTPUT:

Concatenating strings with plus equals operator๐ŸŽฉ

  • We can also get an output with the plus equals operator.

EXAMPLE:

 var bat = "This is my bat "
 bat += "and this is my ball"
 console.log(bat)

OUTPUT:

Constructing strings with variables๐Ÿ“Œ

 var firstCode = " my first coding language was C++."
 var askingYou = "Hi my name is rachit," + firstCode + " What was yours?"
 console.log(askingYou)

OUTPUT:

Activity Time!!!

Let's add a twist to our coding adventure! ๐ŸŽ‰

Step 1: We'll kick things off by creating a variable called myStr and filling it with the word "awesome". Here's how you do it:

javascriptCopy codelet myStr = "awesome";

Step 2: Next, we're crafting another variable called ourStr and this time we're infusing it with "blog is". Here's your line of code:

javascriptCopy codelet ourStr = "blog is";

Step 3: Now, the exciting part! We want to combine these two strings to produce our output: "blog is awesome!" using the += operator. Let's make the magic happen:

javascriptCopy codeourStr += " " + myStr + "!";

And there you have it, folks! We've successfully constructed the phrase "blog is awesome!" with a bit of JavaScript code. Your coding skills are on fire! ๐Ÿ”ฅ๐Ÿ’ป๐Ÿš€

BEST OF LUCK!๐Ÿ’›

Find Length of string๐ŸŽ—

Sometimes you wanna find the length of strings, Javascript makes it easier!! To find the length of the string JS has the special operator called .length

EXAMPLE:

 var code = "Coding is fun" //space is also counted as a lenth
 console.log(code.length)

OUTPUT:

13
  • Here we're getting 13 because it counts the spaces also and also it starts with 0 like 0, 1, 2, 3.....

Bracket Notations to find the characters of strings๐ŸŽฒ

OUTPUT:

N

Bracket Notations to find the last letter!๐Ÿ›’

If you'll just write -1 after the strings then you must get the last letter of the string ๐Ÿ‘†๐Ÿ‘†

Similarly if you write-2then you'll get the second last letter of the string.

Hopefully you are done with the length part!!๐Ÿ’š

You've got this! Learning by doing is the key to mastering coding. ๐Ÿ’ชโค๏ธ

Inspiration for Today: Just remember, every great coder once started as a beginner. So, let's get our hands dirty with some code! ๐Ÿ‘จโ€๐Ÿ’ป

I genuinely hope you all found this article not just useful, but downright awesome! ๐Ÿš€๐Ÿš€๐Ÿš€ If it helped you, please don't hesitate to drop a comment and share your thoughts. Your feedback keeps me motivated and inspired!

So, that's a wrap for Part-3 of our JavaScript for Beginners series. I'll be right back here tomorrow with even more exciting stuff in Part-4. Until then, take care and see you soon! ๐Ÿ‘‹

ย