strings
In this module we'll discuss strings.
Description
Strings are used in every application that you'll ever use, usernames, passwords, lists of products, and anything else that will have a plain English value(other languages too). Strings are a group of characters "strung" (concatenated/added) together. Strings must go in quotes.
File Location
You should be located in the following file:
String Examples
Let's print a few strings to the console:
Variables
Just like integers, we need the var keyword(or const or let) to hold the value in a container. Here are a few examples:
Numbers in a String
You can use numbers in a string, but you won't be able to do math operations. Numbers in quotes are treated as text.
Concatenation
Concatenating happens when we add 2 strings together.
Challenge
QUICK CHALLENGE: See if you can print your own birth city and birth state to the console. What would you have to do?
Strings and Numbers
We can mix strings and integers together.
Another Challenge:
Write a string that has two variables. Output I graduated from Bill Murray High School in 1994.
String Methods
String Methods allow us to introduce functions w/o having to worry about writing them. In JS, Strings, Numbers, and Booleans (not yet covered) have some built in properties and methods that are available through using the .
operator.
We'll talk more about this in the future, but here are a few items to get you familiar with the syntax:
Last updated