mirror of https://github.com/01-edu/public.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.0 KiB
84 lines
2.0 KiB
5 years ago
|
## Using Map
|
||
|
|
||
|
### Instructions
|
||
|
|
||
4 years ago
|
- Create a function named `citiesOnly` which takes an array of objects
|
||
5 years ago
|
and which return an array of strings from the key `city`.
|
||
|
|
||
4 years ago
|
#### Example:
|
||
5 years ago
|
|
||
|
```js
|
||
4 years ago
|
citiesOnly([
|
||
5 years ago
|
{
|
||
|
city: 'Los Angeles',
|
||
|
temperature: ' 101 °F ',
|
||
|
},
|
||
|
{
|
||
|
city: 'San Francisco',
|
||
|
temperature: ' 84 ° F ',
|
||
|
},
|
||
4 years ago
|
]) // -> ['Los Angeles', 'San Francisco']
|
||
5 years ago
|
```
|
||
|
|
||
4 years ago
|
- Create a function named `upperCasingStates` which takes an array of strings
|
||
|
and which Upper Case each words of a string. \
|
||
5 years ago
|
The function returns then an array of strings.
|
||
|
|
||
4 years ago
|
#### Example:
|
||
|
|
||
5 years ago
|
```js
|
||
4 years ago
|
upperCasingStates(['alabama', 'new jersey']) // -> ['Alabama', 'New Jersey']
|
||
5 years ago
|
```
|
||
|
|
||
4 years ago
|
- Create a function named `fahrenheitToCelsius` which takes an array
|
||
5 years ago
|
of fahrenheit temperatures which converts them to Celsius.
|
||
|
Round down the result.
|
||
|
|
||
|
The function then returns the result as an array of strings like below:
|
||
|
|
||
4 years ago
|
#### Example:
|
||
5 years ago
|
|
||
|
```js
|
||
4 years ago
|
fahrenheitToCelsius(['68°F', '59°F', '25°F']) // -> ['20°C', '15°C', '-4°C']
|
||
5 years ago
|
```
|
||
|
|
||
4 years ago
|
- Create a function named `trimTemp` which takes an array of objects
|
||
|
and which removes the spaces from the string in the key `temperature`. \
|
||
5 years ago
|
The function then returns an array of objects with the modification.
|
||
|
|
||
4 years ago
|
#### Example:
|
||
|
|
||
5 years ago
|
```js
|
||
4 years ago
|
trimTemp([
|
||
5 years ago
|
{ city: 'Los Angeles', temperature: ' 101 °F '},
|
||
|
{ city: 'San Francisco', temperature: ' 84 ° F '},
|
||
4 years ago
|
]) /* -> [
|
||
5 years ago
|
{ city: 'Los Angeles', temperature: '101°F' },
|
||
|
{ city: 'San Francisco', temperature: '84°F' },
|
||
4 years ago
|
] */
|
||
5 years ago
|
```
|
||
|
|
||
4 years ago
|
- Create a `tempForecasts` function which will take an array of objects, and which will
|
||
5 years ago
|
return an array of strings formatted as below:
|
||
|
|
||
|
```js
|
||
4 years ago
|
tempForecasts([
|
||
5 years ago
|
{
|
||
|
city: 'Pasadena',
|
||
|
temperature: ' 101 °F',
|
||
|
state: 'california',
|
||
|
region: 'West',
|
||
|
}
|
||
4 years ago
|
]) // -> ['38°Celsius in Pasadena, California']
|
||
5 years ago
|
```
|
||
|
|
||
4 years ago
|
#### Special instruction
|
||
|
|
||
|
The goal of this exercise is to learn to use `map`, as such all your
|
||
|
solution **MUST** use `map`
|
||
|
|
||
|
|
||
5 years ago
|
### Notions
|
||
|
|
||
4 years ago
|
- [devdocs.io/javascript/global_objects/array/map](https://devdocs.io/javascript/global_objects/array/map)
|