🔐

Restricted Access

Enter the password to access Module 1

JavaScript: The Logic Engine

Module 1: Fundamentals of Programming & Data Management

👋 Introduction

Welcome to the JavaScript phase. In web development, we have three core pillars:

  • HTML: The Structure (Content).
  • CSS: The Presentation (Style).
  • JavaScript: The Behavior (Logic).

In this module, we move from creating static pages to building dynamic applications. We will focus on the syntax of the language, how to handle data, and how to execute basic logic using the browser console.

🎯 Learning Objectives (The Roadmap)

  • Foundation & Setup: Understanding the "Big Picture" and linking external `.js` files.
  • Variables: Managing data storage with let vs const (and avoiding var).
  • Data Types & Inspection: Working with String, Number, Boolean and checking types with typeof.
  • Arithmetic & Assignment: Performing math (+ - * / %) and updating values (+=).
  • Comparison & Logic: Making decisions using comparison (===, >) and logical operators (&&, ||, !).
  • Modern Operators: Mastering the Ternary Operator (? :) and Nullish Coalescing (??).
  • String Manipulation: Combining text using operators and understanding Truthy vs Falsy values.

📚 Study Resources (The Curated Path)

Follow this path step-by-step. Watch the video, read the article, and analyze the code example.

1. Introduction to JavaScript

JavaScript makes pages "alive". It runs in the browser and controls how a webpage behaves.

// The most famous line of code
console.log("Hello World"); 
// Result: Prints text to the browser's console
Video
JavaScript - Introduction
A quick high-level overview of what JS is.
Article
MDN: What is JavaScript?
The official introduction by Mozilla.

2. The Big Picture

Understand the history and the "Why" behind JavaScript in less than 2 minutes.

Video
JavaScript in 100 Seconds
Fast-paced overview of the language's capabilities.
Article
W3Schools: JS Introduction
Simple examples of what JS can change (HTML, CSS).

3. Setup & Linking

Just like CSS, we keep JS in a separate file to keep things clean.

<!-- In your index.html file, before the closing body tag -->
<script src="script.js"></script>
Video
JS Setup Tutorial
How to link your .js file correctly.
Article
JS.info: Hello World
Detailed guide on script tags and external files.

4. Variables

Containers for storing data. Use const by default, let if it changes. Avoid var.

let score = 10;      // Can change later
score = 20;          // OK

const name = "KamyCoding"; // Cannot change
// name = "Sarah";   // Error!
Video
JavaScript Variables (Bro Code)
Clear explanation of declaration and assignment.
Video
Variables are Easy!
Visualizing variables as boxes.
Article
W3Schools: JS Variables
Reference guide for let, const, and var.

5. Data Types

In JS, data comes in different flavors: Text (String), Math (Number), and Logic (Boolean).

let message = "Hello"; // String
let price = 99.5;      // Number
let isActive = true;   // Boolean
Video
Data Types (Beau teaches JS)
Quick run-through of all types.
Video
Data Types in 3 Minutes
Fast and concise.
Video
Full Tutorial: Data Types
Deep dive into primitives.
Article
JS.info: Data Types
Detailed reading on types.

6. checking types (typeof)

Not sure what kind of data is in a variable? Ask JS.

console.log(typeof "KamyCoding"); // "string"
console.log(typeof 42);     // "number"
Video
typeof Operator Tutorial
How to inspect your data.
Article
MDN: typeof
Official documentation.

7. Operators (The Toolkit)

Symbols that perform actions on values. We group them by what they do.

A. Arithmetic (Math)

let sum = 10 + 5; // 15
let remainder = 10 % 3; // 1 (Modulus)
Video
Arithmetic Operators
Math in JavaScript.
Article
W3Schools: Arithmetic

B. Assignment (Setting Values)

let x = 10;
x += 5; // Same as: x = x + 5 (Result: 15)
Video
Assignment Operators
Shortcuts for updating variables.
Article
W3Schools: Assignment

C. Logical (And / Or / Not)

let isAdult = true;
let hasTicket = false;
let canEnter = isAdult && hasTicket; // false (Needs BOTH)
Video
JS Logical Operators
&& (AND), || (OR), ! (NOT).
Article
JS.info: Logical Operators

D. Comparison (Comparing Values)

5 > 3;   // true
5 === 5; // true (Strict equality)
5 == "5"; // true (Loose equality - Avoid this!)
Video
Comparison Operators
Greater than, Less than, Equals.
Article
W3Schools: Comparisons

E. Nullish Coalescing (??)

Useful for setting default values if something is null/undefined.

let user;
let name = user ?? "Guest"; // "Guest" because user is undefined
Video
What is Nullish Coalescing?
Handling missing data gracefully.
Article
JS.info: Nullish Coalescing

F. Ternary Operator (Short If/Else)

let age = 18;
let status = (age >= 18) ? "Adult" : "Minor";
Video
The Ternary Operator
One-line decision making.
Article
MDN: Conditional Operator

G. String Operators

let firstName = "Kamyar";
let greeting = "Hello " + firstName; // "Hello Kamyar"
Video
String Operators Explained
Combining text (Concatenation).
Article
W3Schools: JS Operators

H. Truthy & Falsy (Important Concept)

In JS, values like 0, "", null, undefined are considered "false". Everything else is "true".

Video
Truthy and Falsy EXPLAINED
One of the most important parts of JS logic.
Article
MDN: Truthy

🛠️ Practical Lab: The Logic Puzzle

Access Granted! You have been officially invited to the private repository for this week's challenge.

Your Mission Instructions:

  1. Check your GitHub Notifications (or email) and Accept the invitation to the repo.
  2. Clone the repository to your local machine using git.
  3. Open the project in VS Code and find script.js.
  4. Complete the tasks marked with // TODO comments.
Check Invite & Clone

Stuck on a bug? Have a question?

Contact Me on Telegram

💡 KamyCoding Tips: Secrets of Clean Code

1. Naming is Storytelling

Code is read 10x more than it is written. Don't be lazy! Your variable names should explain what is inside without needing comments.

❌ let n = "John"; // What is n? Name? Number?
❌ let User_Data = {...}; // Don't use snake_case in JS
✅ let firstName = "John"; // Clear, descriptive & camelCase

2. The "Const-First" Mindset

Always define variables with const by default. It protects your code from accidental changes. Only switch to let if you logically prove the value needs to change later (like a counter or a score).

💀 Never use var. It's an old keyword from 1995 that causes weird scoping bugs. Treat it as a relic.

3. Talk to "Future You" (Comments)

Write comments to explain WHY you did something, not WHAT you did. The code shows the "what".

// Bad: Adds 10 to score
score = score + 10;

// Good: Bonus points for completing the level
score = score + 10;
"First, solve the problem. Then, write the code."
— John Johnson

© 2025 KamyCoding. All rights reserved.

Designed & Curated by Kamyar Zamanfar