Angular - TypeScript in AngularYou want to create an enum for HTTP status codes with custom numeric values. Which is the correct way to declare it?Aenum HttpStatus = { OK = 200, NotFound = 404, InternalError = 500 }Benum HttpStatus { OK: 200, NotFound: 404, InternalError: 500 }Cenum HttpStatus { OK = 200, NotFound = 404, InternalError = 500 }Denum HttpStatus -> { OK = 200, NotFound = 404, InternalError = 500 }Check Answer
Step-by-Step SolutionSolution:Step 1: Recall enum syntax with assigned valuesUse enum Name { Key = value, ... } with equals signs inside braces.Step 2: Identify correct syntaxenum HttpStatus { OK = 200, NotFound = 404, InternalError = 500 } matches correct syntax for numeric enum values.Final Answer:enum HttpStatus { OK = 200, NotFound = 404, InternalError = 500 } -> Option CQuick Check:Enum with assigned numbers uses '=' inside braces [OK]Quick Trick: Use '=' inside braces for enum value assignments [OK]Common Mistakes:Using ':' instead of '='Using '=' outside bracesUsing arrows instead of braces
Master "TypeScript in Angular" in Angular9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Angular Quizzes Angular Fundamentals - Angular CLI installation and setup - Quiz 6medium Component Interaction - Child to parent communication flow - Quiz 7medium Components - Why components are the building blocks - Quiz 5medium Components - Why components are the building blocks - Quiz 9hard Components - Why components are the building blocks - Quiz 8hard Lifecycle Hooks - Lifecycle execution order mental model - Quiz 1easy Lifecycle Hooks - Why lifecycle hooks matter - Quiz 2easy Lifecycle Hooks - ngOnChanges for input changes - Quiz 13medium TypeScript in Angular - Generics in Angular services - Quiz 6medium TypeScript in Angular - Why TypeScript is required in Angular - Quiz 1easy