Platform
Resources
Pricing
Sign in
Get started
Zach Pino
Workspace
Fork
Public
By
Zach Pino
Edited
Dec 4
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
part1
=
{
let
collector
=
0
;
for
(
let
i
=
0
;
i
<
listA
.
length
;
i
++
)
{
const
distance
=
Math
.
abs
(
listB
[
i
]
-
listA
[
i
]
)
;
collector
=
collector
+
distance
;
}
return
collector
;
}
Insert cell
part2
=
{
let
collector
=
0
;
for
(
let
i
=
0
;
i
<
listA
.
length
;
i
++
)
{
const
a
=
listA
[
i
]
;
const
count
=
listB
.
filter
(
(
b
)
=>
b
==
a
)
.
length
;
collector
=
collector
+
a
*
count
;
}
return
collector
;
}
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
rawData
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
listA
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
listB
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
distances
Edit
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
part1
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
part2
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML