JavaScript for Beginners!   Part-3πŸš€

JavaScript for Beginners! Part-3πŸš€

Β·

3 min read

Hey Coders!! πŸ‘©β€πŸ’»

So, This is the Part-3 of Javascript for Beginners!!πŸ˜‰

And in Part-1 we had learned about Printing Statements, Variables in JS and Arithmetic Operators. Remember??

And in Part-2 we had learned about Incrementing numbers, Decrementing numbers, Shortcuts :(*=, /=), Add 1 to number, Escape sequences in stringsπŸŽƒ

If you have not seen my Part-1 and Part-2 go watch now because in that 2 articles we have talked about the basic things in JS!πŸ˜€

Topic:πŸ‘‡

Concatenating strings with plus operator πŸŽ“

EXAMPLE:

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

OUTPUT:

image.png

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:

image.png

Constructing strings with variablesπŸ“Œ

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

OUTPUT:

image.png

Activity!!πŸ‘©β€πŸ’»

So the activity for you is you need to output: Twitter is awesome But with a twist! I want you code with me!!πŸ’™

  • Step 1: Make a variable name it myStr, inside this write awesome!.

  • Step 2: Make another variable name it ourStr inside this write Twitter is

  • Step 3: Now, I want an output as Twitter is awesome! but you must use += operator!

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"
 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🎲

image.png

OUTPUT:

N

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

image.png

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!!πŸ’š

So, now there is a deal, that you need to write this all and try to understand because, if you just see it you cannot learn it. Hopefully you'll do it!!❀

Motivation for today: Talk is cheap, Show me the codeπŸ‘¨β€πŸ’»

If you guys found this article useful comment πŸš€πŸš€πŸš€!!

So, this was my Javascript for beginners Part-3. Now, I will see you all again tomorrow in my Part-4 till then byee!!πŸ‘‹

Β