Car Price Default Parameter
The function taxRate() is given already in code template. This function will apply 15% tax on car’s price and return the same.
Implement the calculateCarCost() function with car’s ‘price’ and ‘tax’ as parameters.
It returns the total price (totalPrice = price + tax), as shown in the sample output.
Use the function taxRate() in the parameter list to apply value to its second parameter – the default parameter.
The second parameter tax will make use of the first parameter price (price is sent to taxRate() as parameter).
Implement the calculateResellPrice() function with ‘price’ and ‘carAge’ as parameters.
Calculate an estimate for the price of a used vehicle in the dealership, based on the price and carAge and return the same, as shown in the sample output.
Assign carAge parameter – the default parameter, with a default value of ‘1’.
if carAge is ‘1’ then return 80% of the original price as the estimate.
if carAge is ‘5’ then return 70% of the original price as the estimate.
if carAge is ’10’ then return 60% of the original price as the estimate.
if carAge is ’15’ then return 50% of the original price as the estimate.
Note: You may verify the correctness of your function by invoking it from within console.log as shown in sample input and output
Sample Input and Output:
Solution will be released after 150 clicks. How to increase clicks? Click on any AD’s on our site, help us keep running this site as we work for you. 1 person 2 AD Clicks.
- Student Grade Rest Parameter
- Employee Salary Appraisal
- Collection Set E-sale
- Collection Map Weather Report
- Car Price Default Parameter