SpinSpire logo

Strings and Template Literals

Strings and String Methods

let animal = "cats and dogs";
animal.length;
console.log(animal.length); // 13
let animal = "cats, dogs, birds";
let favAnimal = animal.slice(6, 10);
console.log(favAnimal);
// Will display dogs
let text = "SpinSpire is great!";
let newText = text.replace("great", "amazing");
console.log(newText);
// SpinSpire is amazing!
let text = "SpinSpire";
let textTwo = text.toUpperCase();
console.log(textTwo);
// SPINSPIRE
let textThree = "SpinSpire";
let textFour = textThree.toLowerCase();
console.log(textFour);
// spinspire
let textOne = "SpinSpire";
let textTwo = "example";
let textThree = textOne.concat(" ", textTwo);
console.log(textThree);
// SpineSpire example

Template Literals

const food = {
name: "blueberry",
color: "blue"
};

console.log(foodDescription);
// This blueberry is blue.

Note: Some syntax changes