Skip to content

Commit 74f358a

Browse files
author
augenao
committed
Removed duplicated text
1 parent 18b7fd0 commit 74f358a

File tree

1 file changed

+0
-164
lines changed

1 file changed

+0
-164
lines changed

README.md

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -398,167 +398,3 @@ var maxProduct = greatestProduct(matrix);
398398
console.log(maxProduct);
399399
// => 57,148,146
400400
```
401-
402-
function averageNumbers(array){
403-
// Your code here
404-
}
405-
406-
var average = averageNumbers(numbers);
407-
console.log(average);
408-
// 6
409-
```
410-
411-
### Level 2: Array of Strings
412-
413-
Write code to calculate the average *length* of the strings inside of the following array:
414-
415-
```javascript
416-
var words = [
417-
"seat",
418-
"correspond",
419-
"linen",
420-
"motif",
421-
"hole",
422-
"smell",
423-
"smart",
424-
"chaos",
425-
"fuel",
426-
"palace"
427-
];
428-
```
429-
430-
**Starter Code**
431-
432-
```javascript
433-
function averageWordLength(array){
434-
// Your code here
435-
}
436-
437-
var averageLength = averageNumbers(words);
438-
console.log(averageLength);
439-
// 5.3
440-
```
441-
442-
## Unique Arrays
443-
444-
Take the following array, remove the duplicates, and return a new array. You're more than likely going to want to check out the [`indexOf`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) function.
445-
446-
Do this in the form of a function.
447-
448-
**Starter Code**
449-
450-
```javascript
451-
function uniquifyArray(array){
452-
// Your code here
453-
}
454-
455-
var words = [
456-
"crab",
457-
"poison",
458-
"contagious",
459-
"simple",
460-
"bring",
461-
"sharp",
462-
"playground",
463-
"poison",
464-
"communion",
465-
"simple",
466-
"bring"
467-
];
468-
469-
var uniqued = uniquifyArray(words);
470-
console.log(uniqued);
471-
// ["crab", "poison", "contagious", "simple", "bring", "sharp", "playground", "communion"]
472-
```
473-
474-
## Finding Elements
475-
476-
Let's create a simple array search.
477-
478-
Write a function that will take in an array of words as one argument, and a word to search for as the other. Return `true` if it exists, otherwise return `false`. **Don't** use `indexOf` for this one. :)
479-
480-
**Starter Code**
481-
482-
```javascript
483-
var words = [
484-
"machine",
485-
"subset",
486-
"trouble",
487-
"starting",
488-
"matter",
489-
"eating",
490-
"truth",
491-
"disobedience"
492-
];
493-
494-
var hasMatter = doesWordExist(words, "matter");
495-
console.log(hasMatter);
496-
// true
497-
498-
var hasDog = doesWordExist(words, "dog");
499-
console.log(hasDog);
500-
// false
501-
```
502-
503-
## Counting Repetion
504-
505-
Write a function that will take in an array of words as one argument, and a word to search for as the other. The function will return the number of times that word appears in the array.
506-
507-
**Starter Code**
508-
509-
```javascript
510-
var words = [
511-
"machine",
512-
"matter",
513-
"subset",
514-
"trouble",
515-
"starting",
516-
"matter",
517-
"eating",
518-
"matter",
519-
"truth",
520-
"disobedience"
521-
"matter"
522-
];
523-
524-
var howManyMatter = howManyTimes(words, "matter");
525-
console.log(howManyMatter);
526-
// 4
527-
528-
var howManyDog = howManyTimes(words, "dog");
529-
console.log(howManyDog);
530-
// 0
531-
```
532-
533-
## Bonus Quest
534-
535-
In the 20×20 grid below; What is the greatest product of four adjacent numbers in the same direction (up, down, left, right)?
536-
537-
```javascript
538-
var matrix = [
539-
[08,02,22,97,38,15,00,40,00,75,04,05,07,78,52,12,50,77,91,08],
540-
[49,49,99,40,17,81,18,57,60,87,17,40,98,43,69,48,04,56,62,00],
541-
[81,49,31,73,55,79,14,29,93,71,40,67,53,88,30,03,49,13,36,65],
542-
[52,70,95,23,04,60,11,42,69,24,68,56,01,32,56,71,37,02,36,91],
543-
[22,31,16,71,51,67,63,89,41,92,36,54,22,40,40,28,66,33,13,80],
544-
[24,47,32,60,99,03,45,02,44,75,33,53,78,36,84,20,35,17,12,50],
545-
[32,98,81,28,64,23,67,10,26,38,40,67,59,54,70,66,18,38,64,70],
546-
[67,26,20,68,02,62,12,20,95,63,94,39,63,08,40,91,66,49,94,21],
547-
[24,55,58,05,66,73,99,26,97,17,78,78,96,83,14,88,34,89,63,72],
548-
[21,36,23,09,75,00,76,44,20,45,35,14,00,61,33,97,34,31,33,95],
549-
[78,17,53,28,22,75,31,67,15,94,03,80,04,62,16,14,09,53,56,92],
550-
[16,39,05,42,96,35,31,47,55,58,88,24,00,17,54,24,36,29,85,57],
551-
[86,56,00,48,35,71,89,07,05,44,44,37,44,60,21,58,51,54,17,58],
552-
[19,80,81,68,05,94,47,69,28,73,92,13,86,52,17,77,04,89,55,40],
553-
[04,52,08,83,97,35,99,16,07,97,57,32,16,26,26,79,33,27,98,66],
554-
[88,36,68,87,57,62,20,72,03,46,33,67,46,55,12,32,63,93,53,69],
555-
[04,42,16,73,38,25,39,11,24,94,72,18,08,46,29,32,40,62,76,36],
556-
[20,69,36,41,72,30,23,88,34,62,99,69,82,67,59,85,74,04,36,16],
557-
[20,73,35,29,78,31,90,01,74,31,49,71,48,86,81,16,23,57,05,54],
558-
[01,70,54,71,83,51,54,69,16,92,33,48,61,43,52,01,89,19,67,48],
559-
];
560-
561-
var maxProduct = greatestProduct(matrix);
562-
console.log(maxProduct);
563-
// => 57,148,146
564-
```

0 commit comments

Comments
 (0)