Skip to content

Commit 4ed711e

Browse files
committed
ironhack-labs#7 count repetition done
1 parent 26796c6 commit 4ed711e

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

src/functions-and-arrays.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,31 @@ const wordsUnique = [
8484
'bring'
8585
];
8686

87-
function uniquifyArray() {}
88-
87+
function uniquifyArray(arrUni){
88+
let newArray = [];
89+
for (let i = 0;i < arrUni.length; i++){
90+
if (newArray.indexOf(arrUni[i]) === -1){
91+
newArray.push(arrUni[i])
92+
}
93+
}
94+
return newArray
95+
}
96+
console.log(uniquifyArray(wordsUnique))
8997

9098

9199
// Iteration #6: Find elements
92100
const wordsFind = ['machine', 'subset', 'trouble', 'starting', 'matter', 'eating', 'truth', 'disobedience'];
93101

94-
function doesWordExist() {}
102+
function doesWordExist(findArr, theWord){
103+
for (let i = 0;i < findArr.length; i++){
104+
if (findArr[i] === theWord){
105+
return true
106+
} else {
107+
return false
108+
}
109+
}
110+
}
111+
doesWordExist(wordsFind, 'machine')
95112

96113

97114

@@ -110,7 +127,12 @@ const wordsCount = [
110127
'matter'
111128
];
112129

113-
function howManyTimes() {}
130+
function howManyTimes(arrCount, search) {
131+
for (let i = 0;i < arrCount.length; i++){
132+
return arrCount.indexOf(search)
133+
}
134+
}
135+
console.log(howManyTimes(wordsCount, 'matter'))
114136

115137

116138

0 commit comments

Comments
 (0)