@@ -198,97 +198,22 @@ function uniquifyArray(wordsUnique){
198198 return newArr
199199}
200200
201- // function uniquifyArray(arrayOfElements){
202- // if(arrayOfElements.length === 0){
203- // return null
204- // }
205201
206- // let wordsUnique =[]
207202
208- // // arrayOfElements.forEach(word => {
209-
210- // for(let i=0; i < length.arrayOfElements; i++){
211- // if(wordsUnique.includes(!(arrayOfElements[i]))){
212- // wordsUnique.push(word)
213- // console.log(wordsUnique)
214-
215- // }
216- // }
217- // return [...new Set(wordsUnique)]
218- // }
219-
220-
221-
222- // let uniqueList = []
223- // let lenArray = arrayOfElements.length
224-
225- // // arrayOfElements.forEach(function(element))
226- // for (let i=0; i<lenArray; i++){
227-
228- // // if(!(arrayOfElements[i] in uniqueList)){
229- // if(uniqueList.indexOf(element) === -1){
230- // uniqueList.push(arrayOfElements[i])
231- // }
232- // console.log(uniqueList)
233- // }
234- // return uniqueList
235- // }
236-
237- // function uniquifyArray(arrayOfElements){
238- // if(arrayOfElements.length === 0){
239- // return null
240- // }
241- // let newArr =[]
242- // arrayOfElements.forEach(function(element)){
243- // if(newArr.includes(element)) === false){
244- // newArr.push(element)
245- // }
246- // })
247- // return newArr
248- // }
249-
250- // }
251-
252- // function uniquifyArray(wordsUnique){
253-
254- // // if(arrayOfElements.length === 0){
255- // // return null
256- // // }
257-
258- // // let newArr =[]
259-
260-
261- // // for(let i=0; i <wordsUnique.length; i++){
262-
263- // // if(!newArr.includes(wordsUnique[i])) {
264- // // newArr.push(wordsUnique[i])
265- // // }
266-
267-
268- // // return newArr
269- // // }
270- // // }
271-
272-
273- // return [...new Set(wordsUnique) ]
274-
275- // }
276- // wordsUnique.forEach(function(element)){}
277203// Iteration #6: Find elements
278204const wordsFind = [ 'machine' , 'subset' , 'trouble' , 'starting' , 'matter' , 'eating' , 'truth' , 'disobedience' ] ;
279205
280206
281- // function doesWordExist(wordfind, arrayOfWords){
282- // if(arrayOfWords.length === 0){
283- // return null
284- // }
285- // // if(arrayOfWords.includes(wordfind)){
286- // // return true
287- // // }}
207+ function doesWordExist ( wordToFind , arrayOfWords ) {
208+ if ( arrayOfWords . length === 0 ) {
209+ return null
210+ }
211+ if ( arrayOfWords . includes ( wordToFind ) ) {
212+ return true
213+ } else {
214+ return false }
215+ }
288216
289- // return (if(arrayOfWords.includes(wordfind))
290- // }
291- // // }
292217// // Iteration #7: Count repetition
293218
294219const wordsCount = [
0 commit comments