Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a signal in Angular.
Angular
const count = [1](0);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using React hooks like useState instead of Angular signals.
Using ref which is from Vue, not Angular.
✗ Incorrect
In Angular, signal is used to create reactive state that updates the UI automatically.
2fill in blank
mediumComplete the code to update a signal's value.
Angular
count.[1]((prev) => prev + 1);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
set which replaces the value directly, not updates it.Using non-existent methods like
next or change.✗ Incorrect
The update method changes the signal's value based on the current value.
3fill in blank
hardFix the error in the code to read a signal's value.
Angular
const current = count[1]; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to access a property like
.value which does not exist.Using square brackets which are invalid here.
✗ Incorrect
Signals are functions, so to get their value you call them with ().
4fill in blank
hardFill both blanks to create a computed signal that doubles the count.
Angular
const doubleCount = [1](() => count() [2] 2);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
signal instead of computed for derived values.Using addition
+ instead of multiplication.✗ Incorrect
computed creates a signal derived from others. Multiplying count by 2 doubles it.
5fill in blank
hardFill all three blanks to create a signal, update it, and read its value.
Angular
const score = [1](10); score.[2](prev => prev [3] 5);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
computed to create the initial signal.Using
set instead of update when a function is passed.Using subtraction
- instead of addition.✗ Incorrect
Create a signal with signal, update it with update, and add 5 using +.