Advanced freeCodeCamp • top-learn-data-types-and-conditionals

Learn Data Types and Conditionals Lesson A

Lesson Overview

Depending on what kind of work you're doing, you might end up working more with pieces of text rather than numbers. A **string** is a piece of text… and is a fundamental building block of the langu...

Depending on what kind of work you’re doing, you might end up working more with pieces of text rather than numbers. A string is a piece of text… and is a fundamental building block of the language.

HTML provides structure and meaning to text, CSS allows us to precisely style it, and JavaScript offers many features for manipulating strings. These include creating custom welcome messages and prompts, showing the right text labels when needed, sorting terms into the desired order, and much more.

Strings are a fundamental data type in JavaScript. They are used to represent text and are wrapped in either single, double quotes or backticks:

let greeting = "Hello World!";

let greeting2 = 'I am learning JavaScript!';

let greeting3 = `with The Odin Project!`;

Strings declared using single quotes and strings declared using double quotes are the same, and which you use is down to personal preference — although it is good practice to choose one style and use it consistently in your code.