Skip to content

Commit b5b0d7c

Browse files
committed
attempted object chapter examples
1 parent 600e1f7 commit b5b0d7c

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

objects-and-math/chapter-examples/ForInLoop.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@ let tortoiseOne = {
66
diet: ["pumpkins", "lettuce", "cabbage"]
77
};
88

9-
// Using a for..in loop, iterate through each property in the tortoiseOne object and print the value to the console.
9+
// Using a for..in loop, iterate through each property in the tortoiseOne object and print the value to the console.
10+
for (item in tortoiseOne) {
11+
console.log(item + ", " + tortoiseOne[item]);
12+
}
13+

objects-and-math/chapter-examples/KindnessSelection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ function randomSelection(arr){
77

88
let words = ['Hello', 'World', 'Python', 'JavaScript', 'Rutabaga'];
99

10-
for (i=0; i < 8; i++){
10+
let newArray = [];
11+
12+
for (i=0; i < 2; i++){
1113
console.log(randomSelection(happiness));
14+
console.log(randomSelection(words));
1215
}
1316

1417
//Experiment with the code above. Try to:

0 commit comments

Comments
 (0)