Help with a code to calculate distance between 2 coordinates using Latitude and Longitude.

Hello Yisrael,
Thank you for your response. I tried converting them to Numbers, and I still get the NaN. I played around with also converting the numbers to a String and it didn’t help. Could the Problem actually be in the function distance itself?
just so you can see what I tried; and still not working. Thanks for your patience and your help.

$w . onReady (() => {
let lat1 = Number ( $w ( “#userLat” ))
let lat2 = Number ( $w ( “#profileLat” ))
let lon1 = Number ( $w ( “#userLong” ))
let lon2 = Number ( $w ( “#profilelong” ))
$w ( “#distanceMiles” ). value = distance ( lat1 , lon1 , lat2 , lon2 ).toString()
});