Predict Tuple Access Output
Predict Output Easy
Question
What does this code print?
Code
const pair: [string, number] = ["age", 25];
console.log(pair[0]);
console.log(pair[1]);
console.log(pair.length);
Hint
Tuples are arrays — access by index, length gives element count.
Explanation
The tuple pair has two elements: "age" at index 0 and 25 at index 1. pair[0] prints "age", pair[1] prints 25, and pair.length prints 2. The tuple type annotation is erased at runtime.
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.