Defined variables value as Parameters for downstream jobs in jenkinsfile

I have defined a variable in jenkinsfile and it has a dynamic value, so how do i pass the value as parameter in downstream job.

main jenkinsfile
pipeline{
agent any
stages{
stage(‘Checkout stage’){
steps{
script{
name = “karan”
echo “${name}”
}
}
}
stage(‘Checking downstream job’){
steps{
build job: ‘hi job’,
parameters: [string(name: ‘FIRST_NAME’, value: ‘name’)]
}
}
}
}

downstream job

pipeline{
agent any
parameters {
string(name: ‘FIRST_NAME’, description: ‘My custom variable’)
}
stages{
stage(“first”){
steps{
script{
echo “${params.FIRST_NAME}”
echo “hello”

            }    
        }
        
    }
}

}

i want the output be FIRST_NAME be karan but it is showing as name

You would need to define the variable outside the pipeline block if you want to share it between stages. Either that or make it an env variable. Just pass the variable name without quotes around it.