JS Built-ins
StringString.fromCharCodeintermediate

String.fromCharCode() β€” round-trip with charCodeAt

πŸ“– Usage Example
String.fromCharCode(65)        // β†’ 'A'
String.fromCharCode(97)        // β†’ 'a'
String.fromCharCode(72, 105)   // β†’ 'Hi'

Use String.fromCharCode() to create a string from one or more UTF-16 char code values.

String.fromCharCode() β€” Round-trip

You can convert a char to its code with .charCodeAt(0), and back with String.fromCharCode.

Challenge: Implement shiftChar(ch, n) that shifts a character by n positions in the char code table.

shiftChar('A', 1) // β†’ 'B'
shiftChar('a', 2) // β†’ 'c'
πŸ’‘ Hints (1)
  • β€’ Use `ch.charCodeAt(0)` to get the code, then `String.fromCharCode(code + n)` to get the new char.