-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusing-map.js
More file actions
37 lines (32 loc) · 978 Bytes
/
using-map.js
File metadata and controls
37 lines (32 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
function citiesOnly(arr) {
const out = arr.map((obj) => obj["city"])
return out
}
function upperCasingStates(arr) {
const out = arr.map((str) => {
let a = str.split(' ')
const mgad = a.map((elem) => elem.charAt(0).toUpperCase() + elem.slice(1).toLowerCase())
return mgad.join(' ')
}
)
return out
}
function fahrenheitToCelsius(far) {
const out = far.map((elem) => {
let c = (5 / 9) * (parseFloat(elem) - 32)
return Math.floor(c)+ '°C'
}
)
return out
}
function trimTemp(arr) {
const out = arr.map(obj => ({
...obj,
temperature: obj.temperature.replace(/\s/g, '')
}))
return out
}
function tempForecasts(arr) {
const out = arr.map((obj) => String(Math.floor((5 / 9) * (parseFloat(obj.temperature) - 32)) + "°Celsius") + ' in ' + obj.city + ', ' + obj.state.split(" ").map(elem=>(elem[0].toUpperCase() + elem.slice(1).toLowerCase())).join(" "))
return out
}