global variable not accessible in function

I have two global variables dateref and datetest that I call in two functions

the first function updates the value of dateref and datetest

In the second function i need to get the dateref and datetest values updated in the first function

here s what i tried doing in my code

my function:function(req,res){
        var dateref="";
        var datetest="";
 function firstfunction(){
            const jsonref= require ("..\..\..\json\"+req.body.ref);
            const jsontest= require ("..\..\..\json\"+req.body.test);
            this.dateref=date(jsonref);
            this.datetest=date(jsontest);
            //when i console.log dateref or jsontest here i get the updated value
            }
function secondfunction(){
           console.log(dateref)
           console.log(datetest)
           //here dateref and datetest are considered undefined
}