Skip to content

Commit 91f7c70

Browse files
committed
updates to code
1 parent c3f533b commit 91f7c70

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

chapter4/bubbles.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<title>Bubble Factory Test Lab</title>
54
<meta charset="utf-8">
5+
<title>Bubble Factory Test Lab</title>
66
<script>
77
var scores = [60, 50, 60, 58, 54, 54,
88
58, 50, 52, 54, 48, 69,
99
34, 55, 51, 52, 44, 51,
1010
69, 64, 66, 55, 52, 61,
1111
46, 31, 57, 52, 44, 18,
1212
41, 53, 55, 61, 51, 44];
13+
14+
//
15+
// with a while loop
16+
//
1317
var i = 0;
1418
var highScore = 0;
1519
while (i < scores.length) {
@@ -22,16 +26,21 @@
2226
console.log("Bubbles tests: " + scores.length);
2327
console.log("Highest bubble score: " + highScore);
2428

29+
//
30+
// with a for loop
31+
//
2532
for (var i = 0; i < scores.length; i++) {
2633
console.log("Bubble solution #" + i + " score: " + scores[i]);
2734
if (scores[i] > highScore) {
2835
highScore = scores[i];
2936
}
30-
i = i + 1;
3137
}
3238
console.log("Bubbles tests: " + scores.length);
3339
console.log("Highest bubble score: " + highScore);
3440

41+
//
42+
// find the best solution
43+
//
3544
var bestSolutions = [];
3645
for (var i = 0; i < scores.length; i++) {
3746
if (scores[i] == highScore) {

chapter4/bubbles2.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<title>Bubble Factory Test Lab</title>
54
<meta charset="utf-8">
5+
<title>Bubble Factory Test Lab</title>
66
<script>
77
var scores = [60, 50, 60, 58, 54, 54,
88
58, 50, 52, 54, 48, 69,

chapter4/icecream.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<title>Icecream with bubblegum</title>
54
<meta charset="utf-8">
5+
<title>Icecream with bubblegum</title>
66
<script>
77

88
var products = ["Choo Choo Chocolate",

chapter4/phrase-o-matic.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!doctype html>
22
<html lang="en">
33
<head>
4-
<title>Phrase-o-matic</title>
54
<meta charset="utf-8">
5+
<title>Phrase-o-matic</title>
66
<script>
77
function makePhrases() {
88
var words1 = ["24/7", "multi-tier", "30,000 foot", "B-to-B", "win-win"];

0 commit comments

Comments
 (0)