Code Nation INT Unit 3 Lesson 1: Variables and Data Types (Extra Practice)

This is an extension of the coding practice for Unit 3 Lesson 1, found here: https://github.com/itscodenation/int-u3l1-23-24-student-exercises

Come up with a MadLib/story about what happened last class (Disclaimer: Events described might not have actually happened). Instructions can be found in the script.js file. There are additional questions at the end of the script.js file. More information on variables and data types can be found below.


Lesson 3.1: Variables & Data Types

Objective

Learn about variables in JavaScript, how to declare them, assign values, and manipulate their content.

What is a Variable?

  • A variable acts like a box or container storing a piece of information known as its value.
  • Example:
    let box;

Naming a Variable:

  • Variable names should be descriptive and relevant.
  • They follow the camelCase convention (e.g., userName, totalAmount).
  • Restrictions:
    • Cannot start with a number.
    • Cannot be reserved keywords (like let).

Assigning a Value:

  • After declaring a variable, we can assign a value to it.
  • Example:
    let box;
    box = 8;

Data Types:

  • Numbers: Numerical values, can be positive, negative, or decimals.
  • Strings: Series of characters enclosed within quotation marks (either single ' ' or double " ").

Operators:

  • Used to perform arithmetic operations on variables.
  • Basic ones include: +, -, *, /.