Skip to content

Commit f434534

Browse files
committed
day 9
1 parent e7a2adc commit f434534

7 files changed

Lines changed: 2632 additions & 96 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ day9.md
1414
day10.md
1515
01_02_03_days_backup.md
1616
test.md
17-
09_Day
1817
10_Day
1918
11_Day
2019
12_Day

05_Day/05_day_arrays.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
![Day 5](../images/banners/day_1_5.png)
2222

23-
- [📔 Day 5](#-day-5)
23+
- [📔 Day 5](#%f0%9f%93%94-day-5)
2424
- [Arrays](#arrays)
2525
- [How to create an empty array](#how-to-create-an-empty-array)
2626
- [How to create an array with values](#how-to-create-an-array-with-values)
@@ -46,7 +46,7 @@
4646
- [Reversing array order](#reversing-array-order)
4747
- [Sorting elements in array](#sorting-elements-in-array)
4848
- [Array of arrays](#array-of-arrays)
49-
- [💻 Exercise](#-exercise)
49+
- [💻 Exercise](#%f0%9f%92%bb-exercise)
5050

5151
# 📔 Day 5
5252

@@ -520,12 +520,20 @@ Slice: To cut out a multiple items in range. It takes two parameters:starting an
520520
Splice: It takes three parameters:Starting position, number of times to be removed and number of items to be added.
521521

522522
```js
523-
const numbers = [1, 2, 3, 4, 5];
523+
const numbers = [1, 2, 3, 4, 5]
524524

525525
console.log(numbers.splice()) // -> remove all items
526+
527+
```
528+
529+
```js
530+
const numbers = [1, 2, 3, 4, 5]
526531
console.log(numbers.splice(0,1)) // remove the first item
527-
console.log(numbers.splice(3, 3, 6, 7, 8)) // -> [1,2,6,7,8] //it removes two item and replace three items
532+
```
528533

534+
```js
535+
const numbers = [1, 2, 3, 4, 5];
536+
console.log(numbers.splice(3, 3, 6, 7, 8)) // -> [1, 2, 3, 6, 7, 8] //it removes two item and replace three items
529537
```
530538

531539
#### Adding item to an array using push
@@ -563,7 +571,7 @@ console.log(fruits) // ['banana', 'orange', 'mango', 'lemon', 'apple', 'lime']
563571

564572
#### Removing the end element using pop
565573

566-
Pop: Removing item in the end.
574+
pop: Removing item in the end.
567575

568576
```js
569577
const numbers = [1, 2, 3, 4, 5]

08_Day/08_day_objects.md

Lines changed: 4 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717

1818
</div>
1919

20-
[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_function_programming.md) | [Day 9 >>](#)
20+
[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) | [Day 9 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_higher_order_function.md)
2121

2222
![Thirty Days Of JavaScript](../images/banners/day_1_8.png)
2323

24-
- [Day 8](#day-8)
24+
- [📔 Day 8](#%f0%9f%93%94-day-8)
2525
- [Scope](#scope)
2626
- [Window Scope](#window-scope)
2727
- [Global scope](#global-scope)
@@ -39,7 +39,7 @@
3939
- [Checking properties using hasOwnProperty()](#checking-properties-using-hasownproperty)
4040
- [💻 Exercises](#%f0%9f%92%bb-exercises)
4141

42-
# Day 8
42+
# 📔 Day 8
4343

4444
## Scope
4545

@@ -490,94 +490,8 @@ console.log(copyPerson.hasOwnProperty('score'))
490490
1. Get all keys or properties of users object
491491
1. Get all the values of users object
492492
1. Use the countries object to print a country name, capital, populations and languages.
493-
1. \*\*\* Find the 10 most spoken languages:
494493
495-
````js
496-
// Your output should look like this
497-
console.log(mostSpokenLanguages(countries, 10))
498-
[(91, 'English'),
499-
(45, 'French'),
500-
(25, 'Arabic'),
501-
(24, 'Spanish'),
502-
(9, 'Russian'),
503-
(9, 'Portuguese'),
504-
(8, 'Dutch'),
505-
(7, 'German'),
506-
(5, 'Chinese'),
507-
(4, 'Swahili'),
508-
(4, 'Serbian')]
509-
510-
// Your output should look like this
511-
console.log(mostSpokenLanguages(countries, 3))
512-
[
513-
(91, 'English'),
514-
(45, 'French'),
515-
(25, 'Arabic')
516-
]```
517-
518-
````
519-
520-
1. \*\*\* Use countries_data.js file create a function which create the ten most populated countries
521-
522-
````js
523-
console.log(mostPopulatedCountries(countries, 10))
524-
525-
[
526-
{country: 'China', population: 1377422166},
527-
{country: 'India', population: 1295210000},
528-
{country: 'United States of America', population: 323947000},
529-
{country: 'Indonesia', population: 258705000},
530-
{country: 'Brazil', population: 206135893},
531-
{country: 'Pakistan', population: 194125062},
532-
{country: 'Nigeria', population: 186988000},
533-
{country: 'Bangladesh', population: 161006790},
534-
{country: 'Russian Federation', population: 146599183},
535-
{country: 'Japan', population: 126960000}
536-
]
537-
538-
console.log(mostPopulatedCountries(countries, 3))
539-
[
540-
{country: 'China', population: 1377422166},
541-
{country: 'India', population: 1295210000},
542-
{country: 'United States of America', population: 323947000}
543-
]```
544-
545-
````
546-
547-
1. \*\*\* Try to develop a program which calculate measure of central tendency of a sample(mean, median, mode) and measure of variability(range, variance, standard deviation). In addition to those measures find the min, max, count, percentile, and frequency distribution of the sample. You can create an object called statistics and create all the functions which do statistical calculations as method for the statistics object. Check the output below.
548-
549-
```js
550-
const ages = [31, 26, 34, 37, 27, 26, 32, 32, 26, 27, 27, 24, 32, 33, 27, 25, 26, 38, 37, 31, 34, 24, 33, 29, 26]
551-
552-
console.log('Count:', statistics.count()) // 25
553-
console.log('Sum: ', statistics.sum()) // 744
554-
console.log('Min: ', statistics.min()) // 24
555-
console.log('Max: ', statistics.max()) // 38
556-
console.log('Range: ', statistics.range() // 14
557-
console.log('Mean: ', statistics.mean()) // 30
558-
console.log('Median: ',statistics.median()) // 29
559-
console.log('Mode: ', statistics.mode()) // {'mode': 26, 'count': 5}
560-
console.log('Variance: ',statistics.var()) // 17.5
561-
console.log('Standard Deviation: ', statistics.std()) // 4.2
562-
console.log('Variance: ',statistics.var()) // 17.5
563-
console.log('Frequency Distribution: ',statistics.freqDist()) # [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)]
564-
```
565-
566-
```sh
567-
console.log(statistics.describe())
568-
Count: 25
569-
Sum: 744
570-
Min: 24
571-
Max: 38
572-
Range: 14
573-
Mean: 30
574-
Median: 29
575-
Mode: (26, 5)
576-
Variance: 17.5
577-
Standard Deviation: 4.2
578-
Frequency Distribution: [(20.0, 26), (16.0, 27), (12.0, 32), (8.0, 37), (8.0, 34), (8.0, 33), (8.0, 31), (8.0, 24), (4.0, 38), (4.0, 29), (4.0, 25)]
579-
```
580494
581495
🎉 CONGRATULATIONS ! 🎉
582496
583-
[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/09_Day/09_day_function_programming.md) | [Day 9 >>](#)
497+
[<< Day 7](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_functions.md) | [Day 9 >>](https://github.com/Asabeneh/30DaysOfJavaScript/blob/master/07_Day/07_day_higher_order_function.md)

0 commit comments

Comments
 (0)