Build text with template literals and use the most common string methods.
JavaScript · beginner · 5 min · 8 steps · free
const first = 'Ada';
const last = 'Lovelace';
const full = `${first} ${last}`;
const upper = full.toUpperCase();
const initials = first[0] + last[0];
const hasLove = full.includes('Love');
const parts = full.split(' ');
console.log(full.length, upper, initials, hasLove, parts);first is created with the value "Ada".last is created with the value "Lovelace".first and last into the text.toUpperCase returns a new string. full itself does not change.first[0] is the first character, "A". Indexes start at 0.hasLove is created with the value true.split(" ") cuts the text at each space and returns an array of the pieces.12 ADA LOVELACE AL true [ 'Ada', 'Lovelace' ].Hi ${name} builds text.Answer: 3
Answer: Unchanged. Strings are immutable.
← Equality, Truthy and Falsy · if, else and the Ternary →