Question: debug fv.js for TWO errors; then upload only the corrected fv.js . Here is a copy of the current fv.css body { font-family: Arial, Helvetica,
debug fv.js for TWO errors; then upload only the corrected fv.js.
Here is a copy of the current fv.css
body { font-family: Arial, Helvetica, sans-serif; background-color: white; width: 600px; margin: 0 auto; padding: 0 2em 1em; border: 3px solid blue; } h1 { color: blue; margin-bottom: .25em; } label { float: left; width: 11em; text-align: right; } input { margin-left: 1em; margin-bottom: .5em; margin-right: .5em; width: 11em; } span { color: red; }
Then the fv.js
"use strict"; var $ = function (id) { return document.getElementById(id); } var calculateFV = function(investment, rate, years) { var futureValue = investment; for (var i = 1; i <= years; i++ ) { futureValue += futureValue * rate / 100; } futureValue = futureValue.toFixed(2); return futureValue; } var processEntries = function() { var investment = $("investment"); var rate = $("annual_rate"); var years = $("years"); var ok = true; if (investment.value == "") { investment.nextElementSibling.firstChild.nodeValue = "Principal Investment is required."; ok = false; } else if (isNaN(parseFloat(investment.value))) { investment.nextElementSibling.firstChild.nodeValue = "Must be numeric."; ok = false; } else if (investment.value<1 || investment.value>100000) { investment.nextElementSibling.firstChild.nodeValue = "Must be 1..100000."; ok = false; } else { investment.nextElementSibling.firstChild.nodeValue = ""; } if (rate.value == "") { rate.nextElementSibling.firstChild.nodeValue = "Rate is required."; ok = false; } else if (isNaN(parseFloat(rate.value))) { rate.nextElementSibling.firstChild.nodeValue = "Must be numeric."; ok = false; } else if (rate.value<1 || rate.value>15) { rate.nextElementSibling.firstChild.nodeValue = "Must be 1..15."; ok = false; } else { rate.nextElementSibling.firstChild.nodeValue = ""; } if (years.value == "") { years.nextElementSibling.firstChild.nodeValue = "Years is required."; ok = false; } else if (isNaN(parseInt(years.value))) { years.nextElementSibling.firstChild.nodeValue = "Must be integer."; ok = false; } else if (years.value<1 || years.value>50) { years.nextElementSibling.firstChild.nodeValue = "Must be 1..50."; ok = false; } else { years.nextElementSibling.firstChild.nodeValue = ""; } if (ok) { $("future_value").value = calculateFV(parseFloat(investment), parseFloat(rate), parseInt(years)); } else { $("future_value").value = ""; } } window.onload = function () { $("calculate").onclick = processentries; $("investment").focus(); }
then lastly the index.html
Future Value Calculator
** *
Please help.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
