Skip to main content

Featured

๐Ÿ”  Day 8 — Strings & String Methods in JavaScript

๐Ÿ”  Day 8 — Strings & String Methods in JavaScript Welcome to Day 8 ๐ŸŒŸ — Today’s session is all about **Strings**, one of the most common data types in JavaScript. Strings represent text and allow you to store names, messages, or any sequence of characters. ๐Ÿ’ฌ 1️⃣ What is a String? A string is a sequence of characters written inside quotes. let name = "Rahul"; let greeting = 'Hello World'; let message = `Welcome ${name}!`; // Template literal ๐Ÿงฉ 2️⃣ String Properties Strings behave like arrays — they have a .length property and can be accessed using index numbers. let text = "JavaScript"; console.log(text.length); // 10 console.log(text[0]); // J console.log(text[text.length - 1]); // t ๐ŸŽจ 3️⃣ Common String Methods toUpperCase() & toLowerCase() let city = "Hyderabad"; console.log(city.toUpperCase()); console.log(city.toLowerCase()); slice(start, end) let word = "JavaScript"; console.log(word.slice(0, 4)...

๐Ÿงฎ Day 3 — Operators & Expressions in JavaScript

๐Ÿงฎ Day 3 — Operators & Expressions in JavaScript

Welcome to Day 3 ๐ŸŽ‰! Now that you can create variables and work with data, let’s explore how to **perform operations and make logic happen** in your code. Operators are what make JavaScript dynamic — they let you calculate, compare, and assign values, while expressions combine these operators to produce meaningful results.

⚙️ 1️⃣ What Are Operators?

Operators are **symbols** used to perform operations on values and variables. Example: +, -, *, =, ==, etc.

๐Ÿ”ข 2️⃣ Types of Operators

Arithmetic Operators

Used for mathematical calculations:

let a = 10, b = 5;
console.log(a + b); // 15
console.log(a - b); // 5
console.log(a * b); // 50
console.log(a / b); // 2
console.log(a % b); // 0
console.log(a ** 2); // 100

Assignment Operators

Used to assign values to variables.

let x = 10;
x += 5; // x = x + 5
x -= 2; // x = x - 2
x *= 3; // x = x * 3
console.log(x); // 39

Comparison Operators

Used to compare two values and return true or false.

let a = 10, b = "10";
console.log(a == b);  // true  (value only)
console.log(a === b); // false (value + type)
console.log(a != b);  // false
console.log(a > 5);   // true
console.log(a <= 5);  // false

Logical Operators

Used to combine conditions.

  • && — AND (both must be true)
  • || — OR (at least one true)
  • ! — NOT (reverses result)
let age = 20;
console.log(age > 18 && age < 25); // true
console.log(age < 18 || age > 25); // false
console.log(!(age < 18)); // true

String Operators

Used to join strings.

let first = "Rahul";
let last = "Naidu";
console.log(first + " " + last);

๐Ÿงฎ 3️⃣ Expressions

An expression is any valid combination of variables, operators, and values that returns a result.

let result = (10 + 5) * 2;
console.log(result); // 30

๐Ÿง  4️⃣ Practice Task

  1. Create two numbers and find their sum, difference, and product.
  2. Compare two variables using both == and ===.
  3. Use logical operators to check age eligibility.

๐ŸŽฏ Summary

Operators and expressions are the heart of computation in JavaScript. Next, you’ll learn how to **control the flow of your program** using conditional statements — if, else, and switch.

Comments