Guest User

Untitled

a guest
Nov 17th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. // 11: destructuring - string
  2. // To do: make all tests pass, leave the assert lines unchanged!
  3. // Follow the hints of the failure messages!
  4.  
  5. describe('Destructuring also works on strings', () => {
  6. it('destructure every character, just as if the string was an array', () => {
  7. let [a, b, c] = ['a','b','c'];
  8. assert.deepEqual([a, b, c], ['a', 'b', 'c']);
  9. });
  10. it('missing characters are undefined', () => {
  11. const [a, c] = 'a';
  12. assert.equal(c, void 0);
  13. });
  14. it('unicode character work too', () => {
  15. const [space, coffee] = 'a☕';
  16. assert.equal(coffee, '\u{2615}');
  17. });
  18. });
Add Comment
Please, Sign In to add comment