Skip to content

Commit 4ca77f4

Browse files
author
Angela Molina
committed
Updated code sample
1 parent 8289929 commit 4ca77f4

File tree

4 files changed

+4
-45
lines changed

4 files changed

+4
-45
lines changed

5.2-1.js

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
1-
var word = "hello";
2-
var list = ["dog", "cat", "bird"];
3-
4-
greeter(word, list); // arguments
1+
// arguments
52
// "hello dog"
63
// "hello cat"
74
// "hello bird"
85

9-
function greeter(str, arr) { // parameters
10-
var counter;
11-
for (counter = 0; counter < arr.length; counter++) {
12-
console.log(str + " " + arr[counter]);
13-
}
14-
}

5.2-2.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
1-
var greeting = "hello";
2-
var animals = ["dog", "cat", "bird"];
3-
var salutation = "goodbye";
4-
var target = ["moon", "sun"];
51

6-
addresser(greeting, animals);
72
// "hello dog"
83
// "hello cat"
94
// "hello bird"
105

11-
addresser(salutation, target);
6+
127
// "goodbye moon"
138
// "goodbye sun"
149

15-
addresser(greeting, target);
10+
1611
// "hello moon"
1712
// "hello sun"
1813

19-
function addresser(str, arr) {
20-
var counter;
21-
for (counter = 0; counter < arr.length; counter++) {
22-
console.log(str + " " + arr[counter]);
23-
}
24-
}

5.2-3.js

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
console.log(titleCase("hello world."));
2-
// "Hello World."
31

4-
function titleCase(str) {
5-
var strArray = str.split(" ");
6-
var counter;
7-
for (counter = 0; counter < strArray.length; counter++) {
8-
strArray[counter] = capitalize(strArray[counter]);
9-
}
10-
return strArray.join(" ");
11-
}
2+
// "Hello World."
123

13-
function capitalize(str) {
14-
var result = [];
15-
result[0] = str.charAt(0).toUpperCase();
16-
result[1] = str.substring(1);
17-
return (result.join(""));
18-
}

5.2.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
var color = "red";
21

3-
function show(item) {
4-
console.log(item);
5-
}
6-
7-
show(color);
82
// "red"

0 commit comments

Comments
 (0)