Skip to the content.

Fall 2024 - P5

3.4 JavaScript Strings Popcorn Hacks

3.4 JavaScript popcorn hacks

// Find the number of characters in your last name.

// Example:

let last_name = "Williams";
let length = last_name.length;

console.log(length);

// Merge your first and last name together.

// Example: 

let name = "Trent" + " " + "Williams";

console.log(name);

// Show only the 2rd to 8th characters in your name

// Example:

let substring = name.substring(1,8);

console.log(substring);