Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 2.49 KB

File metadata and controls

48 lines (38 loc) · 2.49 KB

Module 2: Variables and Data Types

Activity 1: What are variables?

  • Understanding what variables are and their importance in programming.
  • Exploring the concept of variables as containers for storing and manipulating data.
  • Learning about variable naming conventions and best practices.

Activity 2: Declaring and assigning variables

  • Learning how to declare variables using the var, let, and const keywords.
  • Understanding the difference between mutable and immutable variables.
  • Assigning values to variables using the assignment operator =.
  • Exploring different ways to assign values to variables, including literals and expressions.

Activity 3: Data types in JavaScript

  • Exploring the different data types available in JavaScript, including:
    • Numbers: Understanding number literals and operations.
    • Strings: Manipulating and concatenating strings.
    • Booleans: Working with true and false values.
    • Null and undefined: Understanding these special values.
    • Objects: Introduction to objects and their properties.
  • Understanding type coercion and implicit type conversions in JavaScript.

Practice Exercises:

  1. Calculate the area of a rectangle:

    • Declare two variables, width and height, and assign them appropriate values.
    • Calculate the area of the rectangle by multiplying width and height.
    • Store the result in a variable called area.
    • Finally, log the value of area to the console.
  2. Concatenate strings:

    • Declare two variables, firstName and lastName, and assign them your first and last name respectively.
    • Create a new variable called fullName and concatenate firstName and lastName.
    • Finally, log the value of fullName to the console.
  3. Determine the data type:

    • Declare a variable called data and assign it a value of your choice.
    • Use the typeof operator to determine the data type of data.
    • Finally, log the result to the console.

Estimated time to complete this module is approximately 4-6 hours.

To further enhance your learning, here are some additional resources: