Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

1. Prepare a flowchart of Dr. Mahalees service encounters.

Answered: 1 week ago