TASK 2: Open numberic-variable_problem.js file in a text editor (e.g., NotePad++).
ATTACHED BELOW ARE THE FILES YOU WILL NEED.
numberic-variable_problem.html
<!DOCTYPE html>
<html>
<head>
<title>A3_P2: Numeric Variable</title>
<link rel="stylesheet" href="css/c02.css" />
</head>
<body>
<h1>Elderflower</h1>
<div id="content">
<h2>Custom Signage</h2>
<div id="cost">Cost: $5 per tile</div>
<img src="images/preview.jpg" alt="Sign" />
</div>
<script
src="js/numeric-variable_problem.js"></script>
</body>
</html>
numeric-variable_problem.js
// Create three variables to store the information needed.
var $price;
var 5quantity;
var total;
// Assign values to the price and quantity variables.
$price = 5.95; //illustration for using floating-point numbers
quantity = 0.1; //illustration for using floating-point numbers
// Calculate the total by multiplying the price by
quantity.
total = $price * quantity;
// Get the element with an id of cost.
var el = document.getElementById('cost');
el.textContent = '$' + total;
/*
NOTE: textContent does not work in IE8 or earlier
You can use innerHTML, but note the security issues on
p228-231
el.innerHTML = '$' + total;
*/
c02.css
html {
height: 100%;}
body {
background-color: #b6a996;
background: url('../images/hobart.jpg') no-repeat center center
fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
font-family: helvetica, arial, sans-serif;
font-size: 100%;
margin: 0;
padding: 0;
text-align: center;
min-height: 100%;}
/*#colors {
white-space: pre-line;
}
*/
#content {
background-color: #fff;
border: 3px double #31373f;
color: #31373f;
display: inline-block;
padding: 30px 50px;
margin: 20px auto 50px auto;
max-width: 580px;
min-height: 4em;
overflow: auto;
text-align: center;}
h1, h2 {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;}
h1 {
width: 278px;
height: 112px;
margin: 0 auto 0 auto;
padding-top: 40px;
background: url('../images/elderflower-logo.png') no-repeat bottom
center;}
h2 {
width: 286px;
height: 18px;
margin: 0 auto 20px auto;
background: url('../images/custom-sign.png') no-repeat center
center;}
#title {
font-size: 120%;
font-weight: bold;}
#cost, .action {
background-color: #f84c53;
color: #fff;
width: auto;
height: 1em;
padding: 0.5em 0.75em;
float: right;}
#cost {
position: relative;
top: 1em;
right: 2em;}
.action {
position: relative;
top: 1.3em;
right: -2.3em;}
#note {
background-color: #31373f;
border-radius: 0.5em;
color: #e3bb5a;
padding: 0.5em 1em;
margin-top: 1em;
text-transform: uppercase;
display: inline-block;}
a {
color: #e3bb5a;
text-decoration:none;}
.true, .false {
background: url("../images/tick-cross.png");
display: block;
float:right;
height: 25px;
width: 25px;}
.false {
background-position: 0 -25px;}
.message {
font-weight: bold;
line-height: 1.5em;
height: 2em;
display: block;
clear: left;
min-width: 10em;}
.message span {
font-weight: normal;}
.number {
text-align: left;}
table {
margin: 20px 100px 0 100px;}
tr td:first-child {
font-weight: bold;
padding-right: 20px;}
body:before, body:after {
content: "";
position: fixed;
background: #fff;
left: 0;
right: 0;
height: 20px;}
body:before {
top: 0;}
body:after {
bottom: 0;}
body {
border-left: 20px solid #fff;
border-right: 20px solid #fff;}
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
Syntax Error :
Fixing syntax error :
after using toFixed(3) :
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.
Get Answers For Free
Most questions answered within 1 hours.