Write a javascript function named calculateTradeIn than can do the following cal
ID: 657985 • Letter: W
Question
Write a javascript function named calculateTradeIn than can do the following calculation:
Subtract 15% depreciation of a declining balance for each year based on the difference between the model year and the current year (for example, a 2010 car traded in 2015 would be five years old.) A one year old car is worth 85% of the current trade-in value, a two year old car is worth 72.25%, etc. A simple mathematical calculation can be used to apply the depreciation percentage to the current trade-in value. (HINT: Use Math.pow).
Explanation / Answer
<html>
<head>
<title>JavaScript Math pow() Method</title>
</head>
<body>
<script type="text/javascript">
var value = Math.pow(7, 2);
document.write("First Test Value : " + value );
var value = Math.pow(8, 8);
document.write("<br />Second Test Value : " + value );
var value = Math.pow(-1, 2);
document.write("<br />Third Test Value : " + value );
var value = Math.pow(0, 10);
document.write("<br />Fourth Test Value : " + value );
</script>
</body>
</html>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.