daily pastebin goal
4%
SHARE
TWEET

Untitled

a guest Jul 12th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 15: destructuring - assign
  2. // To do: make all tests pass, leave the assert lines unchanged!
  3.  
  4. describe('assign object property values to new variables while destructuring', () => {
  5. // changed the newname on line 8 to y in the object
  6.   describe('for simple objects', function() {
  7.     it('use a colon after the property name, like so `propertyName: newName`', () => {
  8.       const {x: y} = {x: 1};
  9.       assert.equal(y, 1);
  10.     });
  11.     // added a 4 to fix the ojbect to make it 42
  12.     it('assign a new name and give it a default value using `= <default value>`', () => {
  13.       const {x: y=42} = {y: 23};
  14.       assert.equal(y, 42);
  15.     });
  16.   });
  17. //added :y to fix the fn
  18.   describe('for function parameter names', function() {
  19.     it('do it the same way, with a colon behind it', () => {
  20.       const fn = ({x:y}) => {
  21.         assert.equal(y, 1);
  22.       };
  23.       fn({x: 1});
  24.     });
  25.     // changed the z to a y to make the fn work
  26.     it('giving it a default value is possible too, like above', () => {
  27.       const fn = ({x: y=3}) => {
  28.         assert.equal(y, 3);
  29.       };
  30.       fn({});
  31.     });
  32.   });
  33.  
  34. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top