Skip to content

Commit fd05c80

Browse files
committed
Iteration ironhack-labs#6: Find elements-word in the array
1 parent d648e5c commit fd05c80

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

src/functions-and-arrays.js

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ const numbersAvg = [2, 6, 9, 10, 7, 4, 1, 9];
119119

120120

121121
function averageNumbers(ArrayTobeAveraged){
122+
123+
// checks if the list is empty
122124
if(ArrayTobeAveraged.length ===0){
123125
return null
124126
}
@@ -135,6 +137,7 @@ function averageNumbers(ArrayTobeAveraged){
135137

136138

137139
function avg(arr){
140+
// checks if the list is empty
138141
if(arr.length === 0){
139142
return null
140143
}
@@ -154,6 +157,7 @@ function avg(arr){
154157
const wordsArr = ['seat', 'correspond', 'linen', 'motif', 'hole', 'smell', 'smart', 'chaos', 'fuel', 'palace'];
155158

156159
function averageWordLength(ArrayOfWords){
160+
// checks if the list is empty
157161
if(ArrayOfWords.length===0){
158162
return null
159163
}
@@ -184,6 +188,7 @@ const wordsUnique = [
184188

185189

186190
function uniquifyArray(wordsUnique){
191+
// checks if the list is empty
187192
if (wordsUnique.length === 0){
188193
return null
189194
}
@@ -204,7 +209,8 @@ function uniquifyArray(wordsUnique){
204209
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
205210

206211

207-
function doesWordExist(wordToFind, arrayOfWords){
212+
function doesWordExist(arrayOfWords,wordToFind){
213+
// checks if the list is empty
208214
if(arrayOfWords.length === 0){
209215
return null
210216
}
@@ -230,10 +236,6 @@ const wordsCount = [
230236
'matter'
231237
];
232238

233-
function howManyTimes(wordsArr, wordSearch){
234-
// return wordsArr.filter( a => a == wordSearch).length
235-
// }
236-
237239

238240
function howManyTimes(wordsArr, wordSearch){
239241
let count = 0
@@ -244,7 +246,7 @@ function howManyTimes(wordsArr, wordSearch){
244246
}
245247
return count
246248
}
247-
}
249+
248250
// Iteration #8: Bonus
249251

250252

@@ -273,19 +275,19 @@ const matrix = [
273275
];
274276

275277

276-
function greatestProduct(matrix){
277-
let max=0
278-
for(let i= 0; i<matrix.length;i++){
279-
let rowProd = 1
280-
let colProd = 1
281-
for(let j= 0; j<matrix.length;j++){
282-
for(let k= 0; k<4 ;j++){
283-
rowProd *= mat[y][x] || 0
284-
colProd *= mat[y+1][x] || 0
285-
}
286-
max = Math.max(max,rowProd,colProd)
287-
}
288-
}
289-
}
278+
// function greatestProduct(matrix){
279+
// let max=0
280+
// for(let i= 0; i<matrix.length;i++){
281+
// let rowProd = 1
282+
// let colProd = 1
283+
// for(let j= 0; j<matrix.length;j++){
284+
// for(let k= 0; k<4 ;j++){
285+
// rowProd *= mat[y][x] || 0
286+
// colProd *= mat[y+1][x] || 0
287+
// }
288+
// max = Math.max(max,rowProd,colProd)
289+
// }
290+
// }
291+
// }
290292

291293

0 commit comments

Comments
 (0)