Mark As Completed Discussion

One Pager Cheat Sheet

  • In this lesson, we will discuss how variables are used, as well as specific math operations in programming.
  • A variable is a placeholder for storing data values in a programming language which can be assigned or re-assigned using the equal sign (=).
  • Variables in JavaScript are declared by var, let, or const, and the preferred form for a deep dive is let and const, which offers improved scope over var.
  • The code snippet is invalid due to the lack of a valid variable name after the var keyword.
  • The value of c is assigned the same value as b, which is 10.
  • Using aritmetic operators, one can perform basic math operations like 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 as var c = a + b for more complex calculations.
  • JavaScript provides an abundance of mathematical operations through its Math object, 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) + a which results in 16.
  • JavaScript comes with language-specific operators such as increment (++) and decrement (--) which work differently depending on whether they are pre- or post- placed in relation to a variable.
  • The value of the variable c is decremented by 1 from 96 to 103 when --c is applied before the variable is returned.
  • Basic programming concepts such as variables and mathematical operators are building blocks for developing further techniques, and it is important to ensure no syntax errors occur.