🔠 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)...
Comments
Post a Comment