Regarding using parameters in pipeline

Hi,
I want to take inputs from the user to check the age eligibility to vote .
Below is the code. Build is getting failed .
Please let me know whats wrong with the code :
pipeline{
agent any
parameters {
string defaultValue: ‘10’, description: ‘Please enter your age’, name: ‘Age’
}
stages{
stage(‘condition’){
steps{
script{
def age = $params.Age
if ( age > 18){
echo “Yes,you are eligible to vote”
}
else{
echo " You are not eligible to vote"
}
}
}
}
}
}

Ps ignore the format as i have not formatted the code. just let me know whats wrong with the code.

pipeline{
    agent any
    parameters {
        string defaultValue: ‘10’, description: ‘Please enter your age’, name: ‘Age’
    }
    stages{
        stage(‘condition’){
            steps{
                script{
                    def age = $params.Age ? $params.Age.toInteger() : 0
                    if ( age > 18){
                        echo “Yes,you are eligible to vote”
                    }
                    else{
                        echo " You are not eligible to vote"
                    }
                }
            }
        }
    }
}

On the age > 18 line you are comparing a String object with an Integer which is not possible (shell and perl will let you do that). So you need to cast the age to a integer.

You should be able to use the groovy console from the admin page of Jenkins or one of the online groovy sites to quickly experiment.