File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * Determines whether or not you need a licence to operate a certain kind of vehicle.
3
+ *
4
+ * @param {string } kind
5
+ * @returns {boolean } whether a license is required
6
+ */
7
+ export function needsLicense ( kind ) {
8
+ return ( ( kind === "car" ) || ( kind === "truck" ) ) ;
9
+ }
10
+ /**
11
+ * Helps choosing between two options by recommending the one that
12
+ * comes first in dictionary order.
13
+ *
14
+ * @param {string } option1
15
+ * @param {string } option2
16
+ * @returns {string } a sentence of advice which option to choose
17
+ */
18
+ export function chooseVehicle ( option1 , option2 ) {
19
+ if ( option1 > option2 ) {
20
+ return option2 + " is clearly the better choice." ;
21
+ } else {
22
+ return option1 + " is clearly the better choice." ;
23
+ }
24
+ }
25
+ /**
26
+ * Calculates an estimate for the price of a used vehicle in the dealership
27
+ * based on the original price and the age of the vehicle.
28
+ *
29
+ * @param {number } originalPrice
30
+ * @param {number } age
31
+ * @returns {number } expected resell price in the dealership
32
+ */
33
+ export function calculateResellPrice ( originalPrice , age ) {
34
+ if ( age < 3 ) {
35
+ return 0.8 * originalPrice ;
36
+ } else if ( age > 10 ) {
37
+ return 0.5 * originalPrice ;
38
+ } else {
39
+ return 0.7 * originalPrice ;
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments