Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
A string is simply text - like a person's name, a message, or a sentence. Strings are wrapped in quotes and are one of the most commonly used data types!
'Hello, World!'Most common way
"Hello, World!"Works exactly the same
`Hello, ${name}!`For templates (advanced)
Different ways to create text in JavaScript
Use the + operator to join strings together
stringName.lengthAdd .length after any string
Count how many characters are in strings
Get individual letters from a string using bracket notation
toUpperCase()Make all UPPERCASE
'hello'.toUpperCase() → 'HELLO'toLowerCase()Make all lowercase
'HELLO'.toLowerCase() → 'hello'trim()Remove spaces from ends
' hi '.trim() → 'hi'includes()Check if text exists
'hello'.includes('ell') → trueslice()Cut out a part
'hello'.slice(1, 4) → 'ell'replace()Replace text
'hi'.replace('i', 'o') → 'ho'Transform and manipulate strings with built-in methods
'hello' or "hello" - both work the same
'Hello' + ' ' + 'World' = 'Hello World'
'hello'.length gives you 5 characters
'Hi'[0] is 'H', 'Hi'[1] is 'i'