String Method Chaining
Predict Output Easy
Question
What does this code print?
Code
let s = " Hello World ";
console.log(s.trim().toUpperCase());
Hint
trim removes whitespace from both ends, toUpperCase converts to uppercase.
Explanation
s.trim() removes leading and trailing spaces, giving "Hello World". Then .toUpperCase() converts all characters to uppercase, giving "HELLO WORLD". The output is: HELLO WORLD
Related Resources
Related Lessons
- Strings and Text
Learn about strings.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.