none
Functions inside if statements RRS feed

  • Question

  • I'm trying to make a function that using if statements can call up 1 of 2 other functions but I can't seem to get it working. Below is what I have:

    Function IDcheck1
    {
    If($birth_year -eq $today_year21){
            function IDcheck2
        }  
    Else {
            function IDcheck3
    }
    }



    Function IDcheck2
    {
    If($birthday -ge $21birthday){

        Write-Output "You can drink."
            }  
    Else {
        Write-Host ("You are underage, get out of here with that fake ID before I call your parents!")
    }}


    Function IDcheck3
    {
    If($birth_year -lt $today_year21){

        Write-Output "You can drink."
            }  
    Else {
        Write-Host ("You are underage, get out of here with that fake ID before I call your parents!")
    }}
        IDcheck1

    Wednesday, March 25, 2020 8:36 PM

All replies