Skip to content

Commit e2ef912

Browse files
Merge pull request gouravthakur39#7 from amolmt/master
Convert string to binary in Vanilla JS
2 parents 653b583 + bcc5a0e commit e2ef912

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ConvertStringToBinary/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
@author amolmt
3+
*/
4+
5+
function StringToBinary(string) {
6+
return string
7+
.split("")
8+
.map(function(char) {
9+
return char.charCodeAt(0).toString(2);
10+
})
11+
.join(" ");
12+
}
13+
14+
console.log(StringToBinary("Test"));

0 commit comments

Comments
 (0)