Sitemap

JAVASCRIPT- Part 2

3 min readApr 29, 2026

--

Press enter or click to view image in full size

The Codex (from Beginner to Pro)

Mastering Strings

Strings are everywhere in JavaScript, from user names to messages, APIs, and UI content.
If you don’t understand strings well, you’ll struggle with real-world projects.

Let’s break everything down in a simple, practical way.

Declaring String Variables

A string is just text wrapped in quotes.

let name = "Teejay";
let city = 'Lagos';

console.log(name);
console.log(city);

You can use double (“”) or single (‘’) quotes.

Escaping Literal Quotes

What if your string contains quotes?

let quote = "She said, \"JavaScript is amazing!\"";

console.log(quote);

The backslash \ helps you escape quotes inside a string.

Single vs Double Quotes

Both work the same, but they help avoid escaping.

let sentence1 = "It's a good day"; // no escape needed
let sentence2 = 'She said, "Hello!"';

console.log(sentence1);
console.log(sentence2);

Escape Sequences

Special characters inside strings:

let text = "Hello\nWorld\tJavaScript";

console.log(text);

Common ones:

  • \n → new line
  • \t → tab
  • \\ → backslash

The + Operator

Used to combine strings (concatenation).

let firstName = "Teejay";
let lastName = "Mezue";

let fullName = firstName + " " + lastName;
console.log(fullName);

The += Operator

Append (add) to a string easily.

let message = "Hello";
message += " World";

console.log(message);

Building Strings with Variables

let name = "Teejay";
let age = 25;

let intro = "My name is " + name + " and I am " + age + " years old.";
console.log(intro);

Appending Variables to String

Sometimes, you don’t just want to create a string once; you want to keep adding more information to it using variables.
That’s where appending comes in.

let result = "I love";
let language = " JavaScript";
result += language;

console.log(result);

String Length

Find how many characters are in a string.

let word = "JavaScript";

console.log(word.length); // 10

Bracket Notation

Access characters using index (starts from 0).

let text = "Hello";

console.log(text[0]); // H
console.log(text[1]); // e

String Immutability

let word = "Hello";
word[0] = "Y";

console.log(word); // still "Hello"

Finding Characters

Get the last character:

let text = "JavaScript";

let lastChar = text[text.length - 1];
console.log(lastChar); // t

Word Blanks (Mini Challenge)

Fill in missing words using variables.

let noun = "dog";
let verb = "ran";
let place = "park";

let sentence = "The " + noun + " " + verb + " to the " + place + ".";
console.log(sentence);

Conclusion

You’ve now mastered strings in JavaScript; how to create them, combine them, and work with individual characters.

Get Tochukwu Mezue’s stories in your inbox

Join Medium for free to get updates from this writer.

But in real-world applications, working with just single values isn’t enough.
Most of the time, you’ll deal with collections of data like lists of users, products, scores, and more.

That’s where arrays come in.

👉 Next up: Part 3: Mastering Arrays in JavaScript

Arrays allow you to store multiple values in a single variable and manage them efficiently.

In this part, you’ll learn:

  • Creating arrays
  • Nested arrays
  • Accessing array data
  • Modifying array data
  • Accessing multi-dimensional arrays
  • push()
  • pop()
  • shift()
  • unshift()
  • Building a shopping list

Why This Matters

Arrays are everywhere:

  • Lists of users in an app
  • Items in a cart
  • Quiz questions
  • API data

Once you understand arrays, your JavaScript skills level up instantly.

Get ready, this is where you move from basic coding to building real-world logic

--

--