Back to Cheat Sheets

Writing

JavaScript for Beginners Series - Part 9 (English & Darija)

Part 9 of the JavaScript for Beginners series by Ibtissam Oulahchoum. Learn how to handle text like a pro using Template Literals and essential String Methods (.trim(), .includes(), .split()), with simplified explanations in Moroccan Darija.

JavaScript String Methods ES6 Web Development Darija

January 23, 2026 · 2 min read

JavaScript for Beginners Series - Part 9 (English & Darija)

JavaScript for Beginners: Part 9

Mastering Modern String Manipulation

Welcome to Part 9! Handling text (strings) is one of the most frequent tasks in programming. Today, we’ll look at modern features introduced in ES6 that make your code cleaner and more efficient.

1️⃣ Template Literals (The Backtick `)

Forget the old way of using single (') or double (") quotes. Modern JavaScript uses Backticks.

  • Feature: String Interpolation.
  • How it works: You can drop variables directly inside a string using ${variable} without needing to use the + operator.
🇲🇦 Darija:
هاد العلامة (Backticks) كتخليك تكتب المتغيرات (Variables) وسط النص بلا ماتبقى تسد وتفتح فـ الأقواس ودير علامة الزائد (+). كدير غير ${variable} وكتهنى.

2️⃣Essential String Methods

.trim()

Purpose: Removes all whitespace (spaces, tabs, new lines) from both the start and the end of a string.

  • Use Case: Cleaning up data from a user form.
🇲🇦 Darija:
مهمة بزاف فاش شي واحد كيعمر شي Formulaire وكيدير Espace (فراغ) فاللخر ديال سميتو أو الايميل ديالو بالغلط. هاد الفونكسيون كتمسح دوك الفراغات الجانبية باش الداتا تكون نقية.

.includes()

Purpose: Checks if a string contains a specific word or character.

  • Returns: true or false.
🇲🇦 Darija:
هادي هي اللي كنخدمو فاش كنبغيو نديرو الـ "Search" (بحث). كتقلب واش شي كلمة كاينة وسط النص. مثلاً واش الايميل فيه العلامة ديال "@"، كترجع ليك إما true ولا false.

.split()

Purpose: Breaks a string into pieces and puts them into an Array.

  • Use Case: Processing a list of items separated by commas.
🇲🇦 Darija:
كتقسم ليك النص وكتردو ليك Array. صالحة بزاف إيلا كانت عندك داتا مفروقة بفاصلة (CSV) وبغيتي تخدم على كل كلمة بوحدها.

Code Examples

// Data setup
const firstName = "   Amine   ";
const role = "Developer";

// 1. TEMPLATE LITERALS 
// Notice how we clean the name with .trim() inside the backticks
const greeting = `Hello, ${firstName.trim()}. You are a ${role}.`;

console.log(greeting); 
// Output: "Hello, Amine. You are a Developer."


// 2. USEFUL METHODS
const email = "user@example.com";
const tags = "react,javascript,css";

// Check for a specific character (Search)
console.log(email.includes("@")); // Result: true

// Convert a comma-separated string into an Array
const tagList = tags.split(",");
console.log(tagList); 
// Result: ["react", "javascript", "css"]

Related Cheat Sheets

Mentorship

Want to learn, not just read?

These cheat sheets are the short version. If you want the long one, I teach — one on one, at your pace, on what you are actually trying to build.

Let's talk
  • Learn with guidance

    I will walk you through the fundamentals, review your code, and help you grow past the tutorials.

  • Choose your career path

    Not sure which direction to take? We will talk it through and map a path that fits your strengths and your goals.

Want to work together?

I'm always open to discussing new projects.

Get in Touch