JavaSCript: Assignment - Variable, Data types, Operators

Self learning tutorials : basic Javascript with HTML , CSS examples

Assignment - Variables, Data Types, Operators,

  1. Create two variables: One that holds a new user input (some number of your choice) and another which has no value at first(e.g. "outcome").
  2. Set the outcome variable to 10 plus the value stored in user input.
  3. Add three additional lines of code where you change the outcome variable again (by subtracting a value of your choice, multiplying it and dividing it).
  4. Think about the value stored in the user input variable you also created - did that value change?
  5. alert() the outcome and the user input variables (in two separate alert() calls).

What are JavaScript Variables and Constants?

When to use constants

Use constants whenever the data will never change. This makes your intentions clear and helps make your code easier to understand.