DrSchool Learn coding, fast.
EN AR BN CS DE EL Search

Loops — Example 78

Quick explanation + ready code for: Loops.

PowerShell Loops Back to examples
Back to language
Syntax: Loops in PowerShell. ID: #78

Code

$sum=0
1..23 | ForEach-Object { $sum += $_ }
Write-Host $sum

Notes

You can copy this snippet and adapt it. For advanced, add real-world inputs, edge cases, and tests.