One Pager Cheat Sheet
- In this lesson, we will discuss how
variablesare used, as well as specific math operations in programming. - A variable is a
placeholderfor storing data values in a programming language which can be assigned or re-assigned using theequal sign(=). - Variables in JavaScript are declared by
var,let, orconst, and the preferred form for a deep dive isletandconst, which offers improved scope overvar. - The code snippet is invalid due to the lack of a valid
variable nameafter thevarkeyword. - The value of
cis assigned the same value asb, which is 10. - Using aritmetic operators, one can perform basic
math operationslike addition, subtraction, multiplication, division, modulus and exponentiation in any programming language. - Math operations in JavaScript can be performed by directly specifying a mathematical statement or by assigning the result to a variable
c, such asvar c = a + bfor more complex calculations. - JavaScript provides an abundance of mathematical operations through its
Mathobject, and you can see examples of some of these with the available list at Mozilla Developer Network. - The output of the code block is
Math.sqrt(b) + awhich results in 16. - JavaScript comes with language-specific operators such as
increment(++)anddecrement(--)which work differently depending on whether they are pre- or post- placed in relation to a variable. - The value of the
variablecis decremented by 1 from 96 to 103 when--cis applied before thevariableis returned. - Basic programming concepts such as
variablesandmathematical operatorsare building blocks for developing further techniques, and it is important to ensure no syntax errors occur.


