Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create an array with three numbers.
PowerShell
$numbers = @([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons instead of commas to separate values.
Using dots instead of commas.
✗ Incorrect
In PowerShell, arrays are created using @() with comma-separated values inside.
2fill in blank
mediumComplete the code to access the second element of the array.
PowerShell
$secondElement = $numbers[[1]] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 2 or 3 as the index for the second element.
Forgetting that indexing starts at zero.
✗ Incorrect
PowerShell arrays use zero-based indexing, so the second element is at index 1.
3fill in blank
hardFix the error in the code to add an element to the array.
PowerShell
$numbers [1] 4
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' which does not modify the original array.
Using '-=' or '*=' which are incorrect here.
✗ Incorrect
Use '+=' to add an element to an existing array in PowerShell.
4fill in blank
hardFill both blanks to create an array of numbers from 4 to 12.
PowerShell
$evens = @((2[1]10)[2]2)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using commas instead of the range operator.
Using '-' instead of '+'.
✗ Incorrect
Use the range operator '..' to create numbers from 2 to 10, then add 2 to each element to get numbers from 4 to 12.
5fill in blank
hardFill all three blanks to create a filtered array of numbers greater than 3.
PowerShell
$filtered = $numbers | Where-Object { $_ [1] [2] } | Sort-Object -Descending | Select-Object -First [3] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators like '-lt'.
Selecting wrong number of elements.
✗ Incorrect
Use '-gt' to filter numbers greater than 3, then select the first 5 after sorting descending.