frontend-dorset/javascript/exercises/9/exercise-9-3.html

77 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Women4IT - JavaScript</title>
<meta name="description" content="Women4IT JavaScript Exercise: Variables -1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<!-- Customise Bootstrap for practical grid layouts -->
<link rel="stylesheet" href="../assets/css/bootstrap-custom.css">
<style>
.container {
padding-top: 40px
}
.js-box {
border: solid 1px yellow;
padding: 20px;
background-color: lightyellow;
margin-bottom: 48px;
font-size: larger;
}
#resultBox,
#resultNum {
border: solid 1px green;
height: 40px;
background-color: #E7FFE7;
width: 280px;
padding: 3px 12px;
}
</style>
</head>
<body>
<div class="container col-md-8 offset-md-2">
<h1><b>Exercise 9-3</b>: JavaScript Arrays</h1>
<p>&nbsp;</p>
<h3>Reading array values with a for Loop</h3>
<div class="js-box">
<script>
let authors;
authors = new Array;
authors[0] = "Goddard";
authors[1] = "Grisham";
authors[2] = "Christie";
authors[3] = "Bryson";
authors[4] = "Heller";
authors[5] = "Jerome";
for (i = 0; i <= authors.length; i++) {
document.write("<p>" + authors[i] + "<\/p>");
}
</script>
</div>
</div>
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>