Show Menu
Cheatography

freecodecamp_js Cheat Sheet (DRAFT) by

....................

This is a draft cheat sheet. It is a work in progress and is not finished yet.

10) Declare a Read-Only Variable with the const

const FAV_PET = "­Cat­s";
it cannot be reassi­gned.

11) Add Two Numbers with JavaScript

const myVar = 5 + 10;

12) Subtract One Number from Another

const myVar = 12 - 6;

13) Multiply Two Numbers with JavaScript

const myVar = 13 * 13;

14) Divide One Number by Another with JavaScript

const myVar = 16 / 2;

15) Increment a Number with JavaScript

i++;

16) Decrement a Number with JavaScript

i--;

16) Create Decimal Numbers with JavaScript

const ourDecimal = 5.7;
 

1) Comment Your JavaScript Code

// This is an in-line comment.
/* This is a multi-line comment */

2) Declare JavaScript Variables

var myVar; let myLet; const myConst;

3) Unders­tanding Uninit­ialized Variables

When JavaScript variables are declared, they have an initial value of undefined. If you do a mathem­atical operation on an undefined variable your result will be NaN which means "Not a Number­". If you concat­enate a string with an undefined variable, you will get a string of undefined.

9) Explore Differ­ences Between the var and let

unlike var, when you use let, a variable with the same name can only be declared once.
 

3) Storing Values with the Assignment Operator

myVariable = 5;