Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a signal with an initial value of 0.
Angular
const count = signal([1]); Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using null or undefined as initial value causes unexpected behavior.
Leaving the initial value empty causes errors.
✗ Incorrect
The signal function creates a reactive signal. Here, we start with 0 as the initial value.
2fill in blank
mediumComplete the code to update the signal value by adding 1.
Angular
count.set(count.[1]() + 1);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'value' or 'current' which are not valid methods.
Trying to access the signal value directly without a method.
✗ Incorrect
Use get() to read the current value of a signal before updating it.
3fill in blank
hardComplete the code to create a signal with initial value 'user'.
Angular
const userModel = [1]('user');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-existent functions like 'modelSignal' or 'inputSignal'.
Confusing Angular signals with other frameworks.
✗ Incorrect
The correct function to create a signal in Angular is signal. Other options are invalid.
4fill in blank
hardFill both blanks to create a signal and update it with a new value.
Angular
const name = [1](''); name.[2]('Alice');
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' instead of 'set' to change the value.
Using 'createSignal' which is not an Angular function.
✗ Incorrect
Use signal to create the signal and set to update its value.
5fill in blank
hardFill all three blanks to create a signal, read its value, and update it conditionally.
Angular
const age = [1](20); const currentAge = age.[2](); if (currentAge < 30) { age.[3](currentAge + 1); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' instead of 'set' to change the value.
Trying to read the signal value without calling a method.
✗ Incorrect
Create the signal with signal, read its value with get(), and update it with set().