Leaflet: Fit Polyline in View

I’ve been playing with the Leaflet.js library over the Christmas holidays to visualize running routes drawn onto the map using a Polyline and I wanted to zoom the map the right amount to see all the points.
Pre-Requisites
We have the following HTML to define the div that will contain the map.

Link: https://dzone.com/articles/leaflet-fit-polyline-in-view?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev