Skip to content

Commit 0b946d0

Browse files
committed
day 8
1 parent 51f31ed commit 0b946d0

8 files changed

Lines changed: 2657 additions & 37 deletions

File tree

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ day9.md
1414
day10.md
1515
01_02_03_days_backup.md
1616
test.md
17-
08_Day
1817
09_Day
1918
10_Day
2019
11_Day
21-
12_Day
20+
12_Day
21+
test.html

05_Day/05_day_arrays.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ An array is a collection of different data types which are ordered and changeabl
5959
### How to create an empty array
6060

6161
In JavaScript, we can create an array in different ways. Let us different ways to create an array.
62+
It is very common to use *const* instead of *let* to declare an array variable. If you ar using const it means you do not use that name again.
6263

6364
- Using Array constructor
6465

07_Day/07_day_functions.md

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -552,14 +552,21 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
552552
```
553553

554554
18. Declare a function name _printArray_. It takes array as a parameter and it prints out each value of the array.
555-
19. Declare a function name _swapValues_. This function swaps value of x to y.
555+
19. 11. Write a function name _showDateTime_ which shows time in this format: 08/01/2020 04:08 using the Date object.
556+
557+
```sh
558+
showDateTime()
559+
08/01/2020 04:08
560+
```
561+
562+
20. Declare a function name _swapValues_. This function swaps value of x to y.
556563

557564
```js
558565
swapValues(3, 4) // x => 4, y=>3
559566
swapValues(4, 5) // x = 5, y = 4
560567
```
561568

562-
20. Declare a function name _reverseArray_. It takes array as a parameter and it returns the reverse of the array (don't use method).
569+
21. Declare a function name _reverseArray_. It takes array as a parameter and it returns the reverse of the array (don't use method).
563570

564571
```js
565572
console.log(reverseArray([1, 2, 3, 4, 5]))
@@ -568,44 +575,44 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
568575
//['C', 'B', 'A']
569576
```
570577

571-
21. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray.
572-
22. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item
573-
23. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item
574-
24. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range.
575-
25. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range.
576-
26. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range.
577-
27. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
578+
22. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray.
579+
23. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item
580+
24. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item
581+
25. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range.
582+
26. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range.
583+
27. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range.
584+
28. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
578585

579586
```sh
580587
evensAndOdds(100);
581588
The number of odds are 50.
582589
The number of evens are 51.
583590
```
584591

585-
28. Write a function which takes any number of arguments and return the sum of the arguments
592+
29. Write a function which takes any number of arguments and return the sum of the arguments
586593

587594
```js
588595
sum(1, 2, 3) // -> 6
589596
sum(1, 2, 3, 4) // -> 10
590597
```
591598

592-
29. Writ a function which generates a _randomUserIp_.
593-
30. Write a function which generates a _randomMacAddress_
594-
31. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.
599+
30. Writ a function which generates a _randomUserIp_.
600+
31. Write a function which generates a _randomMacAddress_
601+
32. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.
595602

596603
```sh
597604
console.log(randomHexaNumberGenerator());
598605
'#ee33df'
599606
```
600607

601-
32. Declare a function name _userIdGenerator_. When this function is called it generates seven character id. The function return the id.
608+
33. Declare a function name _userIdGenerator_. When this function is called it generates seven character id. The function return the id.
602609

603610
```sh
604611
console.log(userIdGenerator());
605612
41XTDbE
606613
```
607614

608-
33. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesn’t take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated.
615+
34. Modify question number n . Declare a function name _userIdGeneratedByUser_. It doesn’t take any parameter but it takes two inputs using prompt(). One of the input is the number of characters and the second input is the number of ids which are supposed to be generated.
609616

610617
```sh
611618
userIdGeneratedByUser()
@@ -624,18 +631,18 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
624631
'
625632
```
626633

627-
34. Write a function name _rgbColorGenerator_ and it generates rgb colors.
634+
35. Write a function name _rgbColorGenerator_ and it generates rgb colors.
628635

629636
```sh
630637
rgbColorGenerator()
631638
rgb(125,244,255)
632639
```
633640

634-
35. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array.
635-
36. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array.
636-
37. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color.
637-
38. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color.
638-
39. Write a function **_generateColors_** which can generate any number of hexa or rgb colors.
641+
36. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array.
642+
37. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array.
643+
38. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color.
644+
39. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color.
645+
40. Write a function **_generateColors_** which can generate any number of hexa or rgb colors.
639646

640647
```js
641648
console.log(generateColors('hexa', 3)) // ['#a3e12f', '#03ed55', '#eb3d2b']
@@ -644,13 +651,13 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
644651
console.log(generateColors('rgb', 1)) // 'rgb(33,79, 176)'
645652
```
646653

647-
40. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array
648-
41. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number
649-
42. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not
650-
43. Call your function _sum_, it takes any number of arguments and it returns the sum.
651-
44. Write a function called _sumOfArrayItems_, it takes an array parameter and return the sum of all the items. Check if all the array items are number types. If not give return reasonable feedback.
652-
45. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback.
653-
46. Write a function called _modifyArray_ takes array as parameter and modifies the fifth item of the array and return the array. If the array length is less than five it return 'item not found'.
654+
41. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array
655+
42. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number
656+
43. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not
657+
44. Call your function _sum_, it takes any number of arguments and it returns the sum.
658+
45. Write a function called _sumOfArrayItems_, it takes an array parameter and return the sum of all the items. Check if all the array items are number types. If not give return reasonable feedback.
659+
46. Write a function called _average_, it takes an array parameter and returns the average of the items. Check if all the array items are number types. If not give return reasonable feedback.
660+
47. Write a function called _modifyArray_ takes array as parameter and modifies the fifth item of the array and return the array. If the array length is less than five it return 'item not found'.
654661

655662
```js
656663
console.log(modifyArray(['Avocado', 'Tomato', 'Potato','Mango', 'Lemon','Carrot']);
@@ -661,17 +668,17 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
661668
// →'Not Found'
662669
```
663670

664-
47. Write a function called _isPrime_, which checks if a number is prime number.
665-
48. Write a functions which checks if all items are unique in the array.
666-
49. Write a function which checks if all the items of the array are the same data type.
667-
50. JavaScript variable name does not support special characters or symbols except \$ or \_. Write a function **\*isValidVariable** which check if a variable is valid or invalid variable.
668-
51. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique.
671+
48. Write a function called _isPrime_, which checks if a number is prime number.
672+
49. Write a functions which checks if all items are unique in the array.
673+
50. Write a function which checks if all the items of the array are the same data type.
674+
51. JavaScript variable name does not support special characters or symbols except \$ or \_. Write a function **\*isValidVariable** which check if a variable is valid or invalid variable.
675+
52. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique.
669676

670677
```js
671678
sevenRandomNumbers()[(1, 4, 5, 7, 9, 8, 0)]
672679
```
673680

674-
52. Write a function called reverseCountries, it takes countries array and first it copy the array and returns the reverse of the original array
681+
53. Write a function called reverseCountries, it takes countries array and first it copy the array and returns the reverse of the original array
675682

676683
🎉 CONGRATULATIONS ! 🎉
677684

07_Day/07_day_starter/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<body>
99
<h1>30DaysOfJavaScript:07 Day</h1>
10-
<h2>Loops</h2>
10+
<h2>Functions</h2>
1111

1212
<script src="./data/countries.js"></script>
1313
<script src="./scripts/main.js"></script>

0 commit comments

Comments
 (0)