Created
November 19, 2019 04:48
-
-
Save skywalkw3r/33c7a8e3f71b7af9f5f57c598e6aa231 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-Fahrenheit { | |
[CmdletBinding()] | |
Param( | |
[Parameter(ValueFromPipeline=$true, | |
Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[ValidatePattern('^(\d*\.)?\d+$')] | |
[decimal]$CelsiusTemp | |
) | |
[PSCustomObject]@{ | |
Fahrenheit = "$(($CelsiusTemp*1.8)+32)" | |
Celsius = "$CelsiusTemp" | |
} | |
} | |
function Get-Celsius { | |
[CmdletBinding()] | |
Param( | |
[Parameter(ValueFromPipeline=$true, | |
Mandatory=$true)] | |
[ValidateNotNullOrEmpty()] | |
[ValidatePattern('^(\d*\.)?\d+$')] | |
[decimal]$FahrenheitTemp | |
) | |
[PSCustomObject]@{ | |
Celsius = "$(($FahrenheitTemp-32)/1.8)" | |
Fahrenheit = "$FahrenheitTemp" | |
} | |
} |
Thanks for the feedback!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feel free to check out my response to the challenge.
https://gist.github.com/thedavecarroll/458429ec442b109ea8d6ba46b9ed7b18
Regarding your solution, here's a couple notes:
Get-Verb
to help pick the verb to use for best practice. Convert, ConvertFrom, and ConvertTo from the Data group seems to be the best choice, in my opinion.[decimal]
type.These challenges are fun. I hope you think so, too.
Thanks for your submission. I'm sure the Chairman is pleased. :)