const areAllStr = names.some(name => typeof name === 'number')
const areAllStr = names.some((name) => typeof name === 'number')
console.log(areAllStr) // false
console.log(areAllStr) // false
```
```
### sort
### sort
_sort_: The sort methods arranges the array elements either ascending or descending order. By default, the **_sort()_** method sorts values as strings.This works well for string array items but not for numbers. If number values are sorted as strings and it give us wrong result. Sort method modify the original array. It is recommended to copy the original data before you start using _sort_ method.
_sort_: The sort methods arranges the array elements either ascending or descending order. By default, the **_sort()_** method sorts values as strings.This works well for string array items but not for numbers. If number values are sorted as strings and it give us wrong result. Sort method modify the original array. It is recommended to copy the original data before you start using _sort_ method.
@ -541,7 +541,7 @@ const users = [
{ name: 'Asabeneh', age: 150 },
{ name: 'Asabeneh', age: 150 },
{ name: 'Brook', age: 50 },
{ name: 'Brook', age: 50 },
{ name: 'Eyo', age: 100 },
{ name: 'Eyo', age: 100 },
{ name: 'Elias', age: 22 }
{ name: 'Elias', age: 22 },
]
]
users.sort((a, b) => {
users.sort((a, b) => {
if (a.age <b.age)return-1
if (a.age <b.age)return-1
@ -568,7 +568,7 @@ const products = [
{ product: 'potato', price: ' ' },
{ product: 'potato', price: ' ' },
{ product: 'avocado', price: 8 },
{ product: 'avocado', price: 8 },
{ product: 'coffee', price: 10 },
{ product: 'coffee', price: 10 },
{ product: 'tea', price: '' }
{ product: 'tea', price: '' },
]
]
```
```
@ -587,17 +587,17 @@ const products = [
13. Use **_filter_** to filter out countries containing six letters and more in the country array.
13. Use **_filter_** to filter out countries containing six letters and more in the country array.
14. Use **_filter_** to filter out country start with 'E';
14. Use **_filter_** to filter out country start with 'E';
15. Use **_filter_** to filter out only prices with values.
15. Use **_filter_** to filter out only prices with values.
18. Declare a function called getStringLists which takes an array as a parameter and then returns an array only with string items.
16. Declare a function called getStringLists which takes an array as a parameter and then returns an array only with string items.
19. Use **_reduce_** to sum all the numbers in the numbers array.
17. Use **_reduce_** to sum all the numbers in the numbers array.
20. Use **_reduce_** to concatenate all the countries and to produce this sentence: **_Estonia, Finland, Sweden, Denmark, Norway, and IceLand are north European countries_**
18. Use **_reduce_** to concatenate all the countries and to produce this sentence: **_Estonia, Finland, Sweden, Denmark, Norway, and IceLand are north European countries_**
21. Explain the difference between **_some_** and **_every_**
19. Explain the difference between **_some_** and **_every_**
22. Use **_some_** to check if some names' length greater than seven in names array
20. Use **_some_** to check if some names' length greater than seven in names array
23. Use **_every_** to check if all the countries contain the word land
21. Use **_every_** to check if all the countries contain the word land
24. Explain the difference between **_find_** and **_findIndex_**.
22. Explain the difference between **_find_** and **_findIndex_**.
25. Use **_find_** to find the first country containing only six letters in the countries array
23. Use **_find_** to find the first country containing only six letters in the countries array
26. Use **_findIndex_** to find the position of the first country containing only six letters in the countries array
24. Use **_findIndex_** to find the position of the first country containing only six letters in the countries array
27. Use **_findIndex_** to find the position of **_Norway_** if it doesn't exist in the array you will get -1.
25. Use **_findIndex_** to find the position of **_Norway_** if it doesn't exist in the array you will get -1.
28. Use **_findIndex_** to find the position of **_Russia_** if it doesn't exist in the array you will get -1.
26. Use **_findIndex_** to find the position of **_Russia_** if it doesn't exist in the array you will get -1.
### Exercises: Level 2
### Exercises: Level 2
@ -617,24 +617,26 @@ const products = [
````js
````js
// Your output should look like this
// Your output should look like this
console.log(mostSpokenLanguages(countries, 10))
console.log(mostSpokenLanguages(countries, 10))
[(91, 'English'),
[
(45, 'French'),
{country: 'English',count:91},
(25, 'Arabic'),
{country: 'French',count:45},
(24, 'Spanish'),
{country: 'Arabic',count:25},
(9, 'Russian'),
{country: 'Spanish',count:24},
(9, 'Portuguese'),
{country:'Russian',count:9},
(8, 'Dutch'),
{country:'Portuguese', count:9},
(7, 'German'),
{country:'Dutch',count:8},
(5, 'Chinese'),
{country:'German',count:7},
(4, 'Swahili'),
{country:'Chinese',count:5},
(4, 'Serbian')]
{country:'Swahili',count:4},
{country:'Serbian',count:4}
]
// Your output should look like this
// Your output should look like this
console.log(mostSpokenLanguages(countries, 3))
console.log(mostSpokenLanguages(countries, 3))
[
[
(91, 'English'),
{country: 'English',count: 91},
(45, 'French'),
{country: 'French',count: 45},
(25, 'Arabic')
{country: 'Arabic',count: 25},
]```
]```
````
````
@ -665,6 +667,8 @@ const products = [
]
]
```
```
````
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.
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.