JS Built-ins
TextDecoderbeginner

TextDecoder.decode β€” decoded length of 'abc'

πŸ“– Usage Example
const dec = new TextDecoder('utf-8', { fatal: true })
// throws on invalid UTF-8 sequences

Pass { fatal: true } to make decode() throw on invalid byte sequences.

Decoded String Length

Decoding the encoded bytes of 'abc' should give a string of length 3.

Challenge: Verify that decode(encode('abc')).length === 3.

πŸ’‘ Hints (1)
  • β€’ For ASCII strings, the decoded length equals the original string length.