Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var wrapperEle = document.body.querySelector(".wrapper");
- var miles = Number(prompt("What is your estimated miles per year? "));
- var gcost = Number(prompt("Current cost of gasoline in your area? "));
- function mpgCalc(rate) {
- var rate;
- var estimate = miles/rate*gcost;
- wrapperEle.innerHTML = "To drive a car with an MPG rating of " + rate + " for " + miles + " miles at " + gcost + " per gallon would cost " + estimate;
- }
- mpgCalc(12);
- mpgCalc(17);
- mpgCalc(26);
- mpgCalc(29);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement