<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> </head> <body> <script> //Closure Applications - calculate the price of a taxi // . Taxi starting price (within 3 km) 13, after one kilometer every five dollars more than the increase user enter the number of kilometers you can calculate the price of a taxi // If there is congestion, the total price charged more than 10 dollars congestion charges // function Fn () {}; // Fn (); var CAR = ( function () { var Start = 13 is ; // starting at local variable var Total = 0 ; // total local variables return { // normal total . price: function (n-) { IF (n- <= . 3 ) { Total = Start; } the else { Total = Start + (n- - . 3 ) * . 5 } return Total; }, // cost after congestion YD: function (In Flag) { return In Flag ? Total + 10 : Total; } } }) (); the console.log (car.price ( . 5 ));// 23 console.log(car.yd(true)); // 33 console.log(car.price(1)); // 13 console.log(car.yd(false)); // 13 </script> </body> </html>