availlability of a variable outside the brackets"{}"

Hello everybody i am using doble time the function get items to take two number from my dataset and write it on two a variable (is working)
but when i am trying to recall the two variable outside the brackets {}, it give me error that cannot find the variable.

my questions are :
there is a more easy way to retrieve 2 data from 2 different item of a dataset?
how can i use the two variable outside the brackets {} of the get item function?

thank you in advance

$w ( “#dataset2” ). onReady (() => { //acquisizione dati 400mt
$w ( “#dataset2” ). getItems ( 1 , 12 )

        . then (( result ) => {  
           let  run400begm  =  result . items [ 0 ]. beginnerM ; 
            
           $w ( '#Endlvl' ). text  =  run400begm . toFixed ( 2 ). toString ()+ "%" ; 

})

 . catch (( err ) => { 
      
            let  errMsg  =  err . message ; 
            let  errCode  =  err . code ; 
        }); 

       
    $w ( "#dataset2" ). getItems ( 4 ,  12 ) 
    
        . then (( result ) => {  
           let  run3kmgegm  =  result . items [ 0 ]. beginnerM ; 
            
           $w ( '#condlvl' ). text  =  run3kmgegm . toFixed ( 2 ). toString ()+ "%" ; 

})
$w ( ‘#Endlvl’ ). text = run400begm . toFixed ( 2 ). toString ()+ “%” ; HERE IS WHERE I STOP

. catch (( err ) => {

            let  errMsg  =  err . message ; 
            let  errCode  =  err . code ; 
        }); 

}); 

}

Learn more about: JavaScript Scope