← Back to challenges

Convert to Hex

JavaScriptHardloopslogicstrings

Instructions

Create a function that takes a string's characters as ASCII and returns each character's hexadecimal value as a string.

Examples

toHex("hello world") ➞ "68 65 6c 6c 6f 20 77 6f 72 6c 64"

toHex("Big Boi") ➞ "42 69 67 20 42 6f 69"

toHex("Marty Poppinson") ➞ "4d 61 72 74 79 20 50 6f 70 70 69 6e 73 6f 6e"

Notes

  • Each byte must be seperated by a space.
  • All alpha hex characters must be lowercase.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Burglary Series (08): Remove an Entry