diff --git a/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents/index.md b/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents/index.md index 3f29d2957a..4884c2f347 100644 --- a/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents/index.md +++ b/guide/english/certifications/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/binary-agents/index.md @@ -147,6 +147,26 @@ Make sure that each time you transcode a character from binary to decimal, you r * Array.prototype.map +## ![:rotating_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/rotating_light.png?v=3 ":rotating_light:") Alternative Advanced Code Solution: +```js + const binaryAgent = str => str.replace(/\d+./g, char => String.fromCharCode(`0b${char}`)); + + binaryAgent("01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111"); +``` + +## Code Explanation + +* Find all groups of one or more digits followed by one other character +* Replace with a string created from the specified sequence of UTF-16 code units +* Use `0b` to lead the code unit to express that a binary integer literal is being converted. + +## Relevant Links + +* String.fromCharCode() +* String.prototype.replace() +* Convert a string of binary characters to the ASCII equivalents +* Grammar and types/Numeric Literals + ## ![:clipboard:](https://forum.freecodecamp.com/images/emoji/emoji_one/clipboard.png?v=3 ":clipboard:") NOTES FOR CONTRIBUTIONS: * ![:warning:](https://forum.freecodecamp.com/images/emoji/emoji_one/warning.png?v=3 ":warning:") **DO NOT** add solutions that are similar to any existing solutions. If you think it is **_similar but better_**, then try to merge (or replace) the existing similar solution.