Skip to content

itscodenation/flw1-u1l3-23-24-student-exercises

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lesson 1.3: Documentation, Variables & Data Types

🎯 Objectives

  • Understand and use JavaScript variables.
  • Work with basic data types and operators.

Table of Contents

  1. Documentation
  2. JavaScript & Variables
  3. Data Types & Operators

Documentation

  • Documentation is crucial for:
    • Understanding code.
    • Using code.
    • Debugging.
    • Collaborating with peers.
  • Use the Code Nation Coding Guides to refer to class syntax.
  • Remember: Googling is part of a developer's job! Platforms like W3Schools and egghead.io can be invaluable.

JavaScript & Variables

JavaScript Image

  • JavaScript enables dynamic behaviors on a webpage.
  • Variable is a container that holds data.
    let box;
    box = 8;

Rules for naming variables:

  • Cannot start with a number.
  • Cannot be keywords.
    let mySpiritAnimal = "unicorn";  // Valid
    let thisIsAcceptable = "acceptable";  // Valid

Variable Declaration & Assignment:

  • We can declare and assign a value to a variable in two steps or in one step.

    let cake;
    cake = "lemon";
    // OR
    let cake = "lemon";
  • Variables can be reassigned.

    let myBox = 8;
    myBox = 56;  // myBox is now 56

Data Types & Operators

Data Types

  • Numbers: Can be positive/negative and may have decimals.

    let num = 1234;
    let decimalNum = 1.99;
  • Strings: Textual data enclosed in quotes.

    let greeting = "Hello, World!";
    let codeString = "code123";

Arithmetic Operators

  • Basic operators include: +, -, *, /.

    let num1 = 10, num2 = 5;
    let sum = num1 + num2;  // 15
  • Strings can also be concatenated using the + operator.

    let str1 = "Hello, ";
    let str2 = "World!";
    console.log(str1 + str2);  // Hello, World!
  • Mixing data types can produce unexpected results.

    console.log(5 + "cat");  // 5cat

This lesson covered the importance of documentation, declaring variables in JavaScript, the basic data types, and how to perform operations on them. Always remember to refer to documentation when in doubt.

Keep practicing and happy coding!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published