HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <ul><li>script.js</li>
1 <ul><li>script.js</li>
2 </ul><p>JavaScript</p>
2 </ul><p>JavaScript</p>
3 <p>var calculateMiles = function (distance, isBusinessClass) { var percent = 0.18; if (isBusinessClass) { percent += 0.04; } if (distance &gt; 3500) { percent += 0.15; } return distance * percent; }; var calculateFlights = function (distance, isBusinessClass, milesTarget) { var miles = calculateMiles(distance, isBusinessClass); var flights = Math.ceil(milesTarget / miles); return flights; }; // Add an array and loop here var flightsVariantFirst = calculateFlights(3118, true, 15000); var flightsVariantSecond = calculateFlights(3617, false, 15000); console.log('Required number of flights in business class to Valencia: ' + flightsVariantFirst); console.log('Required number of economy flights to Lisbon: ' + flightsVariantSecond); if (flightsVariantFirst &gt; flightsVariantSecond) { console.log('You will save quicker flying economy to Lisbon! Number of flights: ' + flightsVariantSecond); } else { console.log('You will save quicker flying business class to Valencia! Number of flights: ' + flightsVariantFirst); }</p>
3 <p>var calculateMiles = function (distance, isBusinessClass) { var percent = 0.18; if (isBusinessClass) { percent += 0.04; } if (distance &gt; 3500) { percent += 0.15; } return distance * percent; }; var calculateFlights = function (distance, isBusinessClass, milesTarget) { var miles = calculateMiles(distance, isBusinessClass); var flights = Math.ceil(milesTarget / miles); return flights; }; // Add an array and loop here var flightsVariantFirst = calculateFlights(3118, true, 15000); var flightsVariantSecond = calculateFlights(3617, false, 15000); console.log('Required number of flights in business class to Valencia: ' + flightsVariantFirst); console.log('Required number of economy flights to Lisbon: ' + flightsVariantSecond); if (flightsVariantFirst &gt; flightsVariantSecond) { console.log('You will save quicker flying economy to Lisbon! Number of flights: ' + flightsVariantSecond); } else { console.log('You will save quicker flying business class to Valencia! Number of flights: ' + flightsVariantFirst); }</p>
4 <p>Thanks! We’ll fix everything at once!</p>
4 <p>Thanks! We’ll fix everything at once!</p>
5 <h2>Result</h2>
5 <h2>Result</h2>
6 <ol><li>After calculateFlights function, create variable targets, which contains array [3000, 7500, 15000].</li>
6 <ol><li>After calculateFlights function, create variable targets, which contains array [3000, 7500, 15000].</li>
7 <li>After variable targets, create for loop, which goes through array targets from the very first element to the last one using i counter.</li>
7 <li>After variable targets, create for loop, which goes through array targets from the very first element to the last one using i counter.</li>
8 <li>Move into the loop the<strong>entire</strong>code that is written below this loop.</li>
8 <li>Move into the loop the<strong>entire</strong>code that is written below this loop.</li>
9 <li>In calls of calculateFlights function, replace the last argument with the current element of targets array.</li>
9 <li>In calls of calculateFlights function, replace the last argument with the current element of targets array.</li>
10 </ol>
10 </ol>