Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

70 lines (50 sloc) 1.19 KB
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Basic loop example</title>
<style>
* {
box-sizing: border-box;
}
html {
font-family: monospace;
}
body {
width: 700px;
margin: 0 auto;
}
div {
width: 50%;
float: left;
}
</style>
</head>
<body>
<div>
<p>Invoice totals before sales tax ($):</p>
<ul class="before">
</ul>
</div>
<div>
<p>Invoice totals with 6% sales tax added ($):</p>
<ul class="after">
</ul>
</div>
</body>
<script>
var totals = [191.45, 890.56, 67.99, 12.34, 235.64];
var beforeList = document.querySelector('.before');
var afterList = document.querySelector('.after');
for(var i = 0; i < totals.length; i++) {
var listItem = document.createElement('li');
listItem.textContent = totals[i];
beforeList.appendChild(listItem);
}
for(var j = 0; j < totals.length; j++) {
var listItem = document.createElement('li');
listItem.textContent = (totals[j] * 1.06).toFixed(2);
afterList.appendChild(listItem);
}
</script>
</html>
You can’t perform that action at this time.