Platform
Resources
Pricing
Sign in
Get started
Justin Matthew Newman
+1 (804) 832-9881 | Jr. Software Engineer | Metalinguist LLC | github.com/justinmatthewnewman
Workspace
Fork
Published
By
Justin Matthew Newman
Edited
Nov 7, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Method 1
filteredPlainText
=
{
const
filteredPlainText
=
[
]
;
for
(
const
character
of
plainText
)
{
if
(
/[a-zA-Z]/
.
test
(
character
)
)
filteredPlainText
.
push
(
character
)
;
}
return
filteredPlainText
;
}
Insert cell
// Method 2
//plainText.filter((element, index) => {
// if (alphabet.includes(element)) //console.log(element);
//})
Insert cell
// Method 3
//plainText.filter((element, index) => {
// if (/[a-zA-Z]/.test(element)) //plainText.push(element);
//})
Insert cell
Insert cell
// method 1
{
var
encoder
=
[
]
;
for
(
var
i
=
0
;
i
<
26
;
i
++
)
{
encoder
[
i
]
=
{
key
:
alphabet
[
i
]
,
value
:
i
+
1
}
;
}
console
.
log
(
encoder
)
;
return
encoder
;
}
Insert cell
// method 2
encoder
=
{
let
encoder
=
{
}
;
for
(
var
i
=
0
;
i
<
alphabet
.
length
;
i
++
)
{
encoder
[
alphabet
[
i
]
]
=
i
+
1
;
}
return
encoder
;
}
Insert cell
Insert cell
cipherText
=
{
const
cipherText
=
[
]
;
for
(
let
index
=
0
;
index
<
filteredPlainText
.
length
;
++
index
)
{
cipherText
[
index
]
=
encoder
[
filteredPlainText
[
index
]
]
;
}
return
cipherText
;
}
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
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
alphabet
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
plainText
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
filteredPlainText
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Edit
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
encoder
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
cipherText
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