8.3.9: Text to Binary codehs answers code example
Example 1: string to binary javascript
// string to binary
parseInt(num.toString(2));
// binary to string
parseInt(num.toString(2), 2);
Example 2: string to binary javascript
let num = 2020;
let x = +num.toString(2);
console.log(x);