Zachary Cronin
Dev Cronin

Dev Cronin

LEVEL UP with JavaScript! LVL 4

LEVEL UP with JavaScript! LVL 4

Zachary Cronin's photo
Zachary Cronin
·Aug 28, 2021·

2 min read

In this blog series tutorial, I will be covering some of the basic JavaScript programming concepts.

This is geared toward beginners and anyone looking to refresh their knowledge.

Level 4 will cover:

  • Declare String Variables
  • Escaping Literal Quotes in Strings
  • Quoting Strings with Single Quotes
  • Escape Sequences in Strings
  • Concatenating Strings with Plus Operator

Declare String Variables

A string variable is when zero or more characters are enclosed in quotes.

Numbers can also be a string if enclosed in quotes.

let character = "Tempest Cleric"

Escaping Literal Quotes in Strings

Escaping literal quotes is used when you need to use quotes inside of the quotes of the declared string.

This is done using a backslash before both of the actual quotations.

let magicAxe = "Greataxe \"of the Brute\""; 


Greataxe "of the Brute"

Quoting Strings with Single Quotes

When quoting, single quotes or double quotes may be used.

If this is done, care needs to be taken to avoid ending the string with a non-paired single quotation character.

Again the backslash can be used before the quotation character to escape it and prevent the error.

let myTeam = 'The paladin said "I am the strongest"!'


The paladin said, "I am the strongest"!

Escape Sequences in Strings

There are also some special characters that we need to use the backslash to escape.

When we do this, make sure not to add any spaces between escape sequences or words.

Below is a list of some of these possible characters;

\' single quote \" double quote \ backslash \n newline \r carriage return \t tab \b word boundary \f form feed

var character = "Druid\nLevel One";


Level One

Concatenating Strings with Plus Operator

Concatenating strings use the (+) concatenate operator to add strings together. This is used to build a new string. There will be no spaces unless specifically added.

var character = "Moon " + "Druid"; 


Moon Druid

Thank you for reading my blog! This is the Fourth of my series on JavaScript so if you would like to read more, please follow!

Support and Buy me a Coffee

Share this