Module 1 Session 3

Day 3: Introduction to JavaScript – Variables, Data Types, and Basic Operators

Day 3: Introduction to JavaScript – Variables, Data Types, and Basic Operators

JavaScript-ലെ Variables

JavaScriptil variables define cheyyunnathinu moonu main keywords aanu use cheyyuka: `let`, `const`, and `var`. Ellavattinum thanthantha characteristics undu. Nammal ithil `let` um `const` um focus cheyyum karanam modern JavaScriptil ivide importance kooduthal aanu.

`let` Keyword

`let` keyword use cheyyunnathu namukku variable value later update cheyyan vendi aanu. Example:

let age = 20; // Variable declared and initialized
age = 25; // Value updated
console.log(age); // Outputs: 25

Here `let` aanu use cheythathu because `age` enna variableinte value change cheyyunnu.

`const` Keyword

`const` use cheyyunnathu value change cheyyathe constants vendi aanu. Example:

const pi = 3.14;
// pi = 3.15; (This will throw an error because constants cannot be reassigned)

Ivide `const` use cheythathu `pi` value reassign cheyyan pattatha karyam guaranteed cheyyan vendi aanu.

Example 1: Declaring Variables with `let` and `const`

let age = 25;
const name = 'Rahul';
let isStudent = true;
---

JavaScript Data Types

JavaScriptil variables different types of data hold cheyyum. Basic data types aanu:

  • Number: Numeric values store cheyyan (integers and decimals).
  • String: Text values represent cheyyan ("Hello" or 'JavaScript').
  • Boolean: Logical values (`true` or `false`).
  • Object: Properties and values collections represent cheyyan.
  • Array: Multiple values store cheyyunna ordered list.

Examples:

let age = 25; // Number
let name = 'Rahul'; // String
let isStudent = true; // Boolean
---

Basic JavaScript Operators

Operators use cheyyunnathu variables um values um operations perform cheyyan vendi aanu:

1. Arithmetic Operators

Mathematical operations like addition, subtraction, multiplication cheyyan.

Common arithmetic operators:

  • `+`: Addition
  • `-`: Subtraction
  • `*`: Multiplication
  • `/`: Division
  • `%`: Modulus (Remainder)
Example: let x = 10;
let y = 5;
let sum = x + y; // 15
let diff = x - y; // 5
let prod = x * y; // 50
let div = x / y; // 2
---

2. Comparison Operators

Comparison cheythu `true` allenkil `false` value return cheyyum:

  • `==`: Equality
  • `===`: Strict Equality
  • `>`: Greater than
  • `<`: Less than
  • `>=`: Greater than or equal to
  • `<=`: Less than or equal to
Example: let a = 10;
let b = 20;
let isEqual = (a == b); // false
let isGreater = (a > b); // false
---

3. Logical Operators

Multiple conditions check cheyyan:

  • `&&`: Logical AND
  • `||`: Logical OR
  • `!`: Logical NOT
Example: let x = true;
let y = false;
let result = x && y; // false
let orResult = x || y; // true
---

4. Assignment Operators

Values assign cheyyan vendi:

  • `=`: Basic assignment
  • `+=`: Add and assign
  • `-=`: Subtract and assign
  • `*=`: Multiply and assign
  • `/=`: Divide and assign
Example: let x = 10;
x += 5; // x now becomes 15
---

Conclusion

Innu nammal JavaScriptinte fundamental aspects cover cheythu — variables, data types, and basic operators. Next sessionil logical conditionsum loopsum cover cheyyam.

JavaScript Quiz

Question will appear here

Today's Tasks (Practice)

✅ *Test 1:* Create variables `num1`, `num2`, and print their sum.
✅ *Test 2:* Create string variable `name` and log to console.
✅ *Test 3:* Compare `num1` & `num2`.
✅ *Test 4:* Perform arithmetic operations.

Conclusion (Innale Kandathinu Recap)

✔ JavaScript Variables
✔ Data Types
✔ Basic Operators

Also from tomorrow's session we are adding ai tool creation using java, so make sure check tomorrow's session