Skip to content

Commit 031d4a1

Browse files
committed
solved lab- except bonus
1 parent 95a8105 commit 031d4a1

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/functions-and-arrays.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,20 @@ const wordsCount = [
136136
];
137137

138138
function howManyTimes(arrOfWords, word) {
139-
/* const indices = [];
140-
const element = word;
141-
const idx = arrOfWords.indexOf(element); */
139+
let indices = [];
140+
let element = word;
141+
let idx = arrOfWords.indexOf(element);
142142
if (arrOfWords.length === 0) {
143143
return 0;
144144
}
145145
while (idx != -1) {
146146
indices.push(idx);
147147
idx = arrOfWords.indexOf(element, idx + 1);
148148
}
149-
const count = idx;
149+
let count = indices.length;
150150
return count;
151151
}
152152

153-
/* console.log(howManyTimes(wordsCount, 'matter')) */
154-
155153
// Iteration #8: Bonus
156154
const matrix = [
157155
[8, 2, 22, 97, 38, 15, 0, 40, 0, 75, 4, 5, 7, 78, 52, 12, 50, 77, 91, 8],

0 commit comments

Comments
 (0)