You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 07_Day/07_day_functions.md
+41-34Lines changed: 41 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -552,14 +552,21 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
552
552
```
553
553
554
554
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.
556
563
557
564
```js
558
565
swapValues(3, 4) // x => 4, y=>3
559
566
swapValues(4, 5) // x = 5, y = 4
560
567
```
561
568
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).
563
570
564
571
```js
565
572
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
568
575
//['C', 'B', 'A']
569
576
```
570
577
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.
578
585
579
586
```sh
580
587
evensAndOdds(100);
581
588
The number of odds are 50.
582
589
The number of evens are 51.
583
590
```
584
591
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
586
593
587
594
```js
588
595
sum(1, 2, 3) // -> 6
589
596
sum(1, 2, 3, 4) // -> 10
590
597
```
591
598
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.
595
602
596
603
```sh
597
604
console.log(randomHexaNumberGenerator());
598
605
'#ee33df'
599
606
```
600
607
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.
602
609
603
610
```sh
604
611
console.log(userIdGenerator());
605
612
41XTDbE
606
613
```
607
614
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.
609
616
610
617
```sh
611
618
userIdGeneratedByUser()
@@ -624,18 +631,18 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
624
631
'
625
632
```
626
633
627
-
34. Write a function name _rgbColorGenerator_ and it generates rgb colors.
634
+
35. Write a function name _rgbColorGenerator_ and it generates rgb colors.
628
635
629
636
```sh
630
637
rgbColorGenerator()
631
638
rgb(125,244,255)
632
639
```
633
640
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.
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'.
@@ -661,17 +668,17 @@ console.log('Weight of an object in Newton: ', weightOfObject(100, 1.62)) // gra
661
668
// →'Not Found'
662
669
```
663
670
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.
669
676
670
677
```js
671
678
sevenRandomNumbers()[(1, 4, 5, 7, 9, 8, 0)]
672
679
```
673
680
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
0 commit comments