Today we talk about numbers and strings!
you can add “+”
you can subtract “ — ”
you can multiply “*”
you can divide “/”
you can even find the remains of a number with “%”
I set “number” 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 do math with both whole numbers and decimals.
This is all pretty easy to understand so I'm going to let the examples above tell the story.
(Number is still set to 12)
side note if you are wondering why, when you put number ++, it still reads 12. Its because it doesn't show addition until you call it again
We also use math symbols in a quicker, easier way to set a new value to that variable, with “+=,” “*=,” “— =” basically saying take the “number” variable, add 5 to it or multiply it(whatever the symbol), and then set the total to that variable…!
Fun Fact: By putting “++” in front of a number, you will get the answer right away. Instead of when you put it afterward’s, which it gives you the initial value only after you call it.
Now we talk about strings
Strings are a series of characters wrapped around by single or double quotations
“hello” or ‘hello’ = these are both strings.
“1” or ‘1’= this will also return as a “string” since it is wrapped around quotations.
Here I set a variable to “name” and the value of “Jonathan”, we covered this in the first lesson(which is here). Then I call “name” and then output’s the value.
Side Note: If I wanted to put quotations inside my string, like I was quoting an author or a famous person. I would have to put a forward slash to do so:
If you dont do 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 “+” (talked about this also in first lecture):
check out some more….
The Social Media…