Day 5: Strings Deep Dive & Week 1 Mini-Project
Daily Objective
Section titled “Daily Objective”Master modern string manipulation with template literals, inspect string methods, and complete the Week 1 mini-project.
1. Template Literals (${...})
Section titled “1. Template Literals (${...})”Template literals use backticks (`) to interpolate variables and support multi-line strings cleanly:
const item = 'Mechanical Keyboard';const price = 80;const taxRate = 0.21;const total = price * (1 + taxRate);
const summary = `Product: ${item}Subtotal: $${price}Total with VAT: $${total.toFixed(2)}`;console.log(summary);2. Core String Methods
Section titled “2. Core String Methods”const text = 'Mastering Modern JavaScript';console.log(text.length); // 27 charactersconsole.log(text.toUpperCase()); // "MASTERING MODERN JAVASCRIPT"console.log(text.toLowerCase()); // "mastering modern javascript"console.log(text.includes('Modern')); // trueconsole.log(text.slice(0, 9)); // "Mastering"Week 1 Mini-Project: VAT Shopping Receipt Calculator
Section titled “Week 1 Mini-Project: VAT Shopping Receipt Calculator”Project Requirements:
- Declare constants for product name, item price, quantity, and VAT percentage.
- Calculate subtotal, VAT amount, and final total.
- Use string methods to format the product name in uppercase.
- Output a formatted receipt in the console using a multi-line template literal with currency decimals (
.toFixed(2)).