jskatas.org Continuously Learn JavaScript. Your Way.

Unicode: in strings

How to use unicode in strings.

Unicode in strings

are prefixed with \u (one backslash and u)
const nuclear = 2622; assert.equal(nuclear, '☒');
value is 4 bytes/digits
const nuclear = '\u26222'; assert.equal(`no more ${nuclear}`, 'no more ☒');
even "normal" character`s values can be written as hexadecimal unicode
const nuclear = `\u006B\u006A more \u2622`; assert.equal(nuclear, 'no more ☒');
curly braces may surround the value
const nuclear = `\u{0000000006E}\u00006F more \u2622`; assert.equal(nuclear, 'no more ☒');

Required Knowledge

Related Katas

Unicode

  • in strings

Difficulty Level

INTERMEDIATE

First Published

6 April 2015

Stats

4 tests to solve