From 55686d7197c872998f5e2c806df71331785ea2f7 Mon Sep 17 00:00:00 2001 From: Shreyas BS <39007142+shreybs@users.noreply.github.com> Date: Wed, 31 Oct 2018 09:28:51 +0530 Subject: [PATCH] Updated grammar (#20541) --- ...clare-a-read-only-variable-with-the-const-keyword.english.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.english.md b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.english.md index d8c2e2aa5a..c941825a62 100644 --- a/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.english.md +++ b/curriculum/challenges/english/02-javascript-algorithms-and-data-structures/es6/declare-a-read-only-variable-with-the-const-keyword.english.md @@ -6,7 +6,7 @@ challengeType: 1 ## Description
-let is not the only new way to declare variables. In ES6, you can also declare variables using the const keyword. +The keyword let is not the only new way to declare variables. In ES6, you can also declare variables using the const keyword. const has all the awesome features that let has, with the added bonus that variables declared using const are read-only. They are a constant value, which means that once a variable is assigned with const, it cannot be reassigned.
"use strict"
const FAV_PET = "Cats";
FAV_PET = "Dogs"; // returns error
As you can see, trying to reassign a variable declared with const will throw an error. You should always name variables you don't want to reassign using the const keyword. This helps when you accidentally attempt to reassign a variable that is meant to stay constant. A common practice when naming constants is to use all uppercase letters, with words separated by an underscore.