JavaScript in 60 Seconds

Data Types: String

Strings come in primarily 2 flavors in JS:

  1. Strings
  2. Template strings


"A message with spaces must be susrrounded by quotes" // a string 'Single quotes work tooo.'

You can add strings together:

'Hi my name is' + 'Bill'; var name = "Adam"; 'Hello ' + name; /* when we use the quotes we are creating a string. Without the string means we are looking for a variable named `name` and want to insert the value of `name` there there.*/

Template Literals (Template Strings)

Template strings allow you to insert linebreaks (something you can’t easily do with normal strings).

You start and end Template literals with a backtick character.

` Look ma! This respects whitespace and newlines. I can add a JavaScript 'expression' which will evaluate and the RESULT will be placed in the string if I wrap it with $ and {} 5+5 = 10 `