Skip to content

Instantly share code, notes, and snippets.

Last active Nov 1, 2016
What would you like to do?
// Strings
//String Examples
//String Literals
//Double quotes
var string1 = "Hello World";
//Single quotes
var string2 = 'Hello World';
//Template Literals
var templateLiteralString = `Hello World`;
//Both String Literals and Template Literals can use string methods.
console.log(string1.repeat(2)); //Hello WorldHello World
console.log(string1.includes("Hello")); //True
console.log(string1.includes("World")); //True
console.log(string1.indexOf('H')); //0
console.log(string1.indexOf('W')); //6
console.log(string1.startsWith("Hello")); //True
console.log(string1.startsWith("World")); //False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment