Platform
Resources
Pricing
Sign in
Get started
Xavier B.
Workspace
Fork
Published
By
Xavier B.
Edited
Oct 22, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// get the desired data for the exercice
desiredData
=
cars
.
map
(
d
=>
{
var
newd
=
{
name
:
d
[
"Name"
]
[
0
]
.
toUpperCase
(
)
+
d
[
"Name"
]
.
slice
(
1
)
,
// conver to capital letters
origin
:
d
[
"Origin"
]
,
horsepower
:
d
[
"Horsepower"
]
,
weight
:
d
[
"Weight_in_lbs"
]
,
acceleration
:
d
[
"Acceleration"
]
,
}
return
newd
;
}
)
Insert cell
Insert cell
desiredDataOrigin
=
desiredData
.
filter
(
d
=>
{
d
!==
null
// avoid null data
return
d
.
origin
==
selectedOrigin
;
}
)
// filter by origin in selector
.
sort
(
(
a
,
b
)
=>
{
return
b
.
weight
-
a
.
weight
;
}
)
// We sort it by weight
.
filter
(
d
=>
d
.
horsepower
>=
selectedHorsepower
[
0
]
&&
d
.
horsepower
<=
selectedHorsepower
[
1
]
)
;
Insert cell
Insert cell
origins
=
desiredData
.
map
(
car
=>
{
var
value
=
car
[
'origin'
]
;
return
`<option value="${
value
}">${
value
}</option>`
;
}
)
;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maxHorsepower
=
desiredDataOrigin
.
sort
(
(
a
,
b
)
=>
b
.
horsepower
-
a
.
horsepower
)
[
0
]
.
horsepower
Insert cell
Insert cell
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
selectedOrigin
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
selectedHorsepower
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
cars
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
desiredData
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
desiredDataOrigin
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
origins
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
table
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
accelerationAvg
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
maxHorsepower
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML