Problem Statement
Write an enum and demonstrate custom starting index and lookups.
Explanation
Set an explicit start to control numeric values, then show forward (name → value) and reverse (value → name) lookups. Note: reverse mapping works for numeric enums, not string enums.
Code Solution
SolutionRead Only
enum Http { OK = 200, Created, Accepted } // 200,201,202
const v: Http = Http.Accepted; // 202
const name = Http[201]; // 'Created'
enum Flavor { Choco = 'CHOCO', Vanilla = 'VANILLA' }
// Flavor['CHOCO'] // ❌ no reverse mapping for string enums