[Solved] Convert Yards to Miles, Furlongs and Yards


Never mind, figured it out.

const furlongToYard = 220;
const mileToYard = 1760;

class Distance {

    yardsToMilesAndFurlongsReadable(yards) {
        let miles = Math.floor(yards / mileToYard);
        yards = yards % mileToYard;

        let furlongs = Math.floor(yards / furlongToYard);
        yards = yards % furlongToYard;

        return `${miles > 0 ? miles + 'm' : ''} ${furlongs > 0 ? furlongs + 'f' : ''} ${yards > 0 ? yards + 'y' : ''}`;
    }
}

export default Distance;

solved Convert Yards to Miles, Furlongs and Yards