Javascript part 2
By: Jonathan Bleibdrey
Tags: Javascript Tips, JavaScript, Basic Javascritp, Numbers, String

Today we talk about numbers and strings!

I hate number’s, THE END

JUST KIDDING!

I feel the need to go over this because we use it a lot javascript. Whenever I find things to be hard, I tend to go in that direction,

because I know it will lead me somewhere new with the most growth.

Numbers:

you can add, subtract, divide, multiply with javascript. This is pretty self-explanatory, but I will go over it:

you can add “+.”

you can subtract “ — ”

you can multiply “*.”

you can divide “/.”

you can even find the remainder of a number with “%.”

I set the variable to 12 in the example below, then call it instead of actually writing it out. (Why? I DONT KNOW!)

I go over advanced Math methods in a later course…

We can do math with both whole numbers and decimals.

This is all pretty easy to understand so I'm going to let the examples tell the story.

One thing to mention, though. See the “++” or “ — — ” in the bottom example? that is a javascript trick to quickly add or subtract one.

We can also use the math symbols in a quicker, easier way with “+=,” “*=,” “— =” basically saying take “number” and add 5 to it or multiply it, even subtract it, etc…! This isn't rocket science, but I need to show you.

Lastly, this would be the more functional way to add a number the first time. We would just put “++” in front of the number to get the incremented or decremented number first hand. When you put it afterward’s it doesn't give you the initial value, you have to call it afterward’s.

Now we talk about strings

Strings:

Strings are a series of characters wrapped around by single or double quotations

for example:

“hello” or ‘hello’ = these are both strings.

“1” or ‘1’= this will also return “string” since it is wrapped around quotations.

Here I set a variable to “name” and the value to “Jonathan”, we covered this in the first lesson. Then I call “name” and then output’s the value.

Side Note If I wanted to put quotations inside my string I would have to put a forward slash to do so:

If you didn't put the forward-slash it would think you are trying to end the string and give you all types of errors.

Next, if you wanted to concatenate two strings together you would put a “+” (I've beaten this to death at this point, but here is one more time):

When you add them together they gave us “jonathanbleibdrey” together. all we have to do is put an empty quotation in the middle with space to output “jonathan bleibdrey”. ( this is super important because it comes up a lot in javascript.)

ok, thanks that's all for this one, check out my other posts for more javascript fun.

check out some more….

Javascript 1 (link to: variables and data types)

Javascript 2 (link to: numbers and strings)

Javascript 3 (link to: bracket notation and 20 diff string methods)

Javascript 4 (link to: functions and how they work)

Javascript 5 (link to: hoisting, comparison operators, and if-else statements)

Javascript 6 (link to: diff. Equal signs, null, and undefined)

Javascript 7 (link to: logical operator, &&, || and ternary operators)

Javascript 8 (link to: switch statements and arrays)

Javascript 9 (link to: commonly used arrays in javascript)

Javascript 10 (link to: Math. And parseInt Usage)