Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Angular - State Management
Identify the error in this code snippet:
const count = signal(0);
count = signal(5);
console.log(count());
ACalling count() is invalid syntax
BYou cannot reassign a signal variable declared with const
CSignals must be declared with let, not const
DSignals cannot hold numeric values
Step-by-Step Solution
Solution:
  1. Step 1: Check variable declaration

    count is declared with const, so it cannot be reassigned.
  2. Step 2: Identify reassignment error

    The line count = signal(5); tries to reassign count, causing an error.
  3. Final Answer:

    You cannot reassign a signal variable declared with const -> Option B
  4. Quick Check:

    const variables cannot be reassigned = C [OK]
Quick Trick: const signals cannot be reassigned; use .set() to update [OK]
Common Mistakes:
  • Thinking signals must use let
  • Trying to call signal without parentheses
  • Believing signals can't hold numbers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes