Recall & Review
beginner
What is an array in PowerShell?
An array in PowerShell is a collection of items stored in a single variable. It can hold multiple values like numbers, strings, or objects, all together.
Click to reveal answer
beginner
How do you create an array with three numbers: 5, 10, and 15?
You create it by listing the values inside @() like this: <br>
$numbers = @(5, 10, 15)Click to reveal answer
beginner
How do you access the second item in an array named $colors?
Use the index number inside square brackets. Remember, counting starts at 0. So, the second item is
$colors[1].Click to reveal answer
intermediate
How can you add an item to an existing array in PowerShell?
Arrays are fixed size, but you can create a new array by adding items like this: <br>
$newArray = $oldArray + 'newItem'Click to reveal answer
beginner
What happens if you try to access an index that does not exist in an array?
PowerShell returns nothing (null) without an error. It just gives an empty result.
Click to reveal answer
How do you create an empty array in PowerShell?
✗ Incorrect
In PowerShell, an empty array is created with @() syntax.
What is the index of the first element in a PowerShell array?
✗ Incorrect
PowerShell arrays start counting at 0, so the first element is at index 0.
Which of these adds an item 'apple' to an existing array $fruits?
✗ Incorrect
Both += and + create a new array with the added item in PowerShell.
What will $array[10] return if $array has only 5 items?
✗ Incorrect
Accessing an index outside the array returns null or empty without error.
How do you find the number of items in an array $items?
✗ Incorrect
PowerShell arrays support both .Length and .Count properties to get the number of items.
Explain how to create, access, and add items to an array in PowerShell.
Think about how you store a list of things and get or add items.
You got /3 concepts.
What happens if you try to get an array item at an index that does not exist? How does PowerShell handle it?
Imagine asking for a seat number that is not in the theater.
You got /3 concepts.