Getting the value of distance measured and add recommendation

I am currently trying Tomtom routing with summary example(https://developer.tomtom.com/maps-sdk-web-js/functional-examples#examples,code,routing-with-summary.html). I want to get the result/value of distance (in kilometer) and put it in a conditional statement. Example, if the distance between two points is greater than 20km it will show “Place is too far” but i dont know how to properly do it in js.

I want to add suggestion (result of the condition stement) on the commented part
var detailsHTML =

Leave now
’ +
’ +
’ +
’ +
’ +
’ +
'Distance: ’ +
Formatters.formatAsMetricDistance(feature.lengthInMeters) +
’ +
'Suggestion: ’ // I want to add suggestion here
’ +
'Arrive: ’ +
Formatters.formatToExpandedDateTimeString(feature.arrivalTime) +
’ +
’ +
’;

Hello, have you tried an online search for the Haversine formula to calculate the distance between 2 coordinates?

-Jose