function Fn (the src, DST, K) { // n-m cities do flights flying described the let Fights = [ [ 0,1,100 ], [ 1,2,100 ], [ 0,2,500 ] ]; // calculate the cheapest route the let Cheap = (the src, dst, K) => { // find the dst previous stop the let PREV = fights.filter (I => I [. 1] == dst); the let min = Math.min.apply ( null , prev.map (I => { // find the des forward, in fact, found urban IF (I [0] && the src K ===> -1 ) { return I [2] } else if(k===0&&item[0]!=src){ return Number.MAX_SAFE_INTEGER; } else { return i[2] + cheap(src, item[0],k-1) } })) return min; } return cheap(src, dst, k) || -1; }