Skip to content

Commit d5488cb

Browse files
luismunoz83luismunoz83
authored andcommitted
Iteration ironhack-labs#6: Find elements
1 parent b2d07da commit d5488cb

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/functions-and-arrays.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ function sum(num) {
7272
suma += num [i]
7373

7474
}
75-
76-
7775
}
7876

7977
return suma
@@ -117,7 +115,14 @@ function averageWordLength(wordsArr) {
117115
console.log(averageWordLength(wordsArr))
118116

119117
// Bonus - Iteration #4.1
120-
function avg() {}
118+
function avg(words) {
119+
120+
let result= sum(words) / words.length
121+
122+
return result
123+
}
124+
125+
console.log(avg(mixedArr))
121126

122127
// Iteration #5: Unique arrays
123128
const wordsUnique = [
@@ -182,9 +187,25 @@ const wordsCount = [
182187
'disobedience',
183188
'matter'
184189
];
190+
const wordCount = "truth"
191+
192+
function howManyTimes(words, word) {
193+
194+
let count = 0
195+
196+
for (let i = 0; i < words.length; i++) {
197+
198+
if (words[i] === word){
199+
200+
count += 1
185201

186-
function howManyTimes() {}
202+
}
203+
}
187204

205+
return count
206+
207+
}
208+
console.log(howManyTimes(wordsCount,wordCount))
188209

189210

190211
// Iteration #8: Bonus

0 commit comments

Comments
 (0)