Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
var input = 'The example of 1234567 !@#$%^&*()_++'  
console.log('input', input)
const stringToBinary = function(string) {
  let binaryOutput = '';
  for (var i = 0; i < input.length; i++) {
    binaryOutput += input[i].charCodeAt(0).toString(2) + ' ';
  }
  return binaryOutput;
};
const binaryVar = stringToBinary(input);
console.log('binary', binaryVar)
const binaryToString = function(binary) {
  const binaryString = binary.split(' ');
  let stringOutput = '';
  for (let i = 0; i < binaryString.length; i++) {
    stringOutput += String.fromCharCode(parseInt(binaryString[i], 2));
  }
  return stringOutput;
};
console.log('binarytostring', binaryToString(binaryVar))
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers