Question: I am trying to debug my website and I am unsure of what is wrong with it. I know the html and css is right,

I am trying to debug my website and I am unsure of what is wrong with it. I know the html and css is right, but I need to know what I am doing wrong with my JavaScript. My professor told me that there are 3 syntax issues in the ProcessEntrys() and 2 logic issues with the MakeChange()

make_change.js

var $ = function(id) {

return document.getElementById(id);

};

var processEntry = function() {

var entry = $("cents").value; // get user entry

var cents = parseInt(entry); // parse entry

if (isnaN(cents) || cents < 0 || cents > 99) {

alert("Entry must be greater than zero and less 100");

}

else {

makeChange(cents);

}

$("cents").focus();

};

var makeChange = function(cents) {

var quarters = parseInt(cents / 25); // get number of quarters

cents = cents % 25; // assign remainder to cents variable

var dimes = parseInt(cents / 10); // get number of dimes

cents = cents * 10; // assign remainder to cents variable

var nickels = parseInt(cents / 5); // get number of nickels

var pennies = cents % 1; // get number of pennies

// display the results of the calculations

$("quarters").value = quarters;

$("dimes").value = dimes;

$("nickels").value = nickels;

$("pennies").value = pennies;

};

window.onload = function () {

$("calculate").onclick = processEntry;

$("cents").focus();

};

index.html

Make Change

Change Calculator

styles.css

body {

font-family: Arial, Helvetica, sans-serif;

background-color: white;

margin: 0 auto;

width: 600px;

border: 3px solid blue;

}

h1 {

color: blue;

margin-top: 0;

}

main {

padding: 1em 2em;

}

label {

float: left;

width: 16em;

text-align: right;

}

input {

margin-left: 1em;

margin-bottom: .5em;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!