Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First start troubleshooting
[int]$FizzRunningTotal = 0
[int]$FizzBuzzRunningTotal = 0
[int]$BuzzRunningTotal = 0
$Mod15 = [Scriptblock]::Create('param([int]$Number) if ($Number % 15 -eq 0) { $FizzBuzzRunningTotal + $_ }')
$Mod5 = [Scriptblock]::Create('param([int]$Number) if ($Number % 5 -eq 0) { $BuzzRunningTotal + $_ }')
$Mod3 = [Scriptblock]::Create('param([int]$Number) if ($Number % 3 -eq 0) { $FizzRunningTotal + $_ }')
1..15 | ForEach-Object {
[PSCustomObject]@{
Number = $_
FizzRunningTotal = $Mod3.InvokeReturnAsIs($_)
BuzzRunningTotal = $Mod5.InvokeReturnAsIs($_)
FizzBuzzRunningTotal = $Mod15.InvokeReturnAsIs($_)
}
} | Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.