Skip to content

Commit

Permalink
day 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Asabeneh committed Jan 8, 2020
1 parent 51f31ed commit 0b946d0
Show file tree
Hide file tree
Showing 8 changed files with 2,657 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ day9.md
day10.md
01_02_03_days_backup.md
test.md
08_Day
09_Day
10_Day
11_Day
12_Day
12_Day
test.html
1 change: 1 addition & 0 deletions 05_Day/05_day_arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ An array is a collection of different data types which are ordered and changeabl
### How to create an empty array

In JavaScript, we can create an array in different ways. Let us different ways to create an array.
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.

- Using Array constructor

Expand Down
75 changes: 41 additions & 34 deletions 07_Day/07_day_functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -552,14 +552,21 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
```

18. Declare a function name _printArray_. It takes array as a parameter and it prints out each value of the array.
19. Declare a function name _swapValues_. This function swaps value of x to y.
19. 11. Write a function name _showDateTime_ which shows time in this format: 08/01/2020 04:08 using the Date object.

```sh
showDateTime()
08/01/2020 04:08
```

20. Declare a function name _swapValues_. This function swaps value of x to y.

```js
swapValues(3, 4) // x => 4, y=>3
swapValues(4, 5) // x = 5, y = 4
```

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

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

21. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray.
22. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item
23. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item
24. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range.
25. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range.
26. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range.
27. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number.
22. Declare a function name _capitalizeArray_. It takes array as a parameter and it returns the - capitalizedarray.
23. Declare a function name _addItem_. It takes an item parameter and it returns an array after adding the item
24. Declare a function name _removeItem_. It takes an index parameter and it returns an array after removing an item
25. Declare a function name _sumOfNumbers_. It takes a number parameter and it adds all the numbers in that range.
26. Declare a function name _sumOfOdds_. It takes a number parameter and it adds all the odd numbers in that - range.
27. Declare a function name _sumOfEven_. It takes a number parameter and it adds all the even numbers in that - range.
28. Declare a function name evensAndOdds . It takes a positive integer as parameter and it counts number of evens and odds in the number.

```sh
evensAndOdds(100);
The number of odds are 50.
The number of evens are 51.
```

28. Write a function which takes any number of arguments and return the sum of the arguments
29. Write a function which takes any number of arguments and return the sum of the arguments

```js
sum(1, 2, 3) // -> 6
sum(1, 2, 3, 4) // -> 10
```

29. Writ a function which generates a _randomUserIp_.
30. Write a function which generates a _randomMacAddress_
31. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.
30. Writ a function which generates a _randomUserIp_.
31. Write a function which generates a _randomMacAddress_
32. Declare a function name _randomHexaNumberGenerator_. When this function is called it generates a random hexadecimal number. The function return the hexadecimal number.

```sh
console.log(randomHexaNumberGenerator());
'#ee33df'
```

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

```sh
console.log(userIdGenerator());
41XTDbE
```

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.
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.

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

34. Write a function name _rgbColorGenerator_ and it generates rgb colors.
35. Write a function name _rgbColorGenerator_ and it generates rgb colors.

```sh
rgbColorGenerator()
rgb(125,244,255)
```

35. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array.
36. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array.
37. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color.
38. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color.
39. Write a function **_generateColors_** which can generate any number of hexa or rgb colors.
36. Write a function **_arrayOfHexaColors_** which return any number of hexadecimal colors in an array.
37. Write a function **_arrayOfRgbColors_** which return any number of RGB colors in an array.
38. Write a function **_convertHexaToRgb_** which converts hexa color to rgb and it returns an rgb color.
39. Write a function **_convertRgbToHexa_** which converts rgb to hexa color and it returns an hexa color.
40. Write a function **_generateColors_** which can generate any number of hexa or rgb colors.

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

40. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array
41. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number
42. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not
43. Call your function _sum_, it takes any number of arguments and it returns the sum.
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.
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.
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'.
41. Call your function _shuffleArray_, it takes an array as a parameter and it returns a shuffled array
42. Call your function _factorial_, it takes a whole number as a parameter and it return a factorial of the number
43. Call your function _isEmpty_, it takes a parameter and it checks if it is empty or not
44. Call your function _sum_, it takes any number of arguments and it returns the sum.
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.
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.
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'.

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

47. Write a function called _isPrime_, which checks if a number is prime number.
48. Write a functions which checks if all items are unique in the array.
49. Write a function which checks if all the items of the array are the same data type.
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.
51. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique.
48. Write a function called _isPrime_, which checks if a number is prime number.
49. Write a functions which checks if all items are unique in the array.
50. Write a function which checks if all the items of the array are the same data type.
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.
52. Write a function which returns array of seven random numbers in a range of 0-9. All the numbers must be unique.

```js
sevenRandomNumbers()[(1, 4, 5, 7, 9, 8, 0)]
```

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

🎉 CONGRATULATIONS ! 🎉

Expand Down
2 changes: 1 addition & 1 deletion 07_Day/07_day_starter/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<body>
<h1>30DaysOfJavaScript:07 Day</h1>
<h2>Loops</h2>
<h2>Functions</h2>

<script src="./data/countries.js"></script>
<script src="./scripts/main.js"></script>
Expand Down
Loading

0 comments on commit 0b946d0

Please sign in to comment.