Lesson 3 of 15
Strings
Strings
Strings hold text. You can write them with double quotes, single quotes, or backticks:
let a = "hello";
let b = 'world';
let c = `hello world`; // template literal
Concatenation
Use + to join strings together:
let first = "Hello";
let second = "World";
console.log(first + ", " + second + "!"); // Hello, World!
Template Literals
Backtick strings let you embed expressions with ${...}:
let name = "Alice";
let age = 30;
console.log(`${name} is ${age} years old`); // Alice is 30 years old
Useful Methods
let s = "Hello, World!";
console.log(s.length); // 13
console.log(s.toUpperCase()); // HELLO, WORLD!
console.log(s.toLowerCase()); // hello, world!
console.log(s.includes("World")); // true
console.log(s.slice(7, 12)); // World
Your Task
Declare a greeting variable with value "Hello, JavaScript!". Print the greeting, its length, and its uppercase version.
JavaScript loading...
Loading...
Click "Run" to execute your code.