Created
March 1, 2017 09:51
-
-
Save underwindfall/56b1750b18dcf3fcdc6bad407603ef82 to your computer and use it in GitHub Desktop.
Answers of Es6katas [http://es6katas.org/]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 5: arrow functions - basics | |
// To do: make all tests pass, leave the asserts unchanged! | |
describe('arrow functions', function() { | |
it('are shorter to write', function() { | |
var func = () => { | |
return 'I am func'; | |
}; | |
assert.equal(func(), 'I am func'); | |
}); | |
it('a single expression, without curly braces returns too', function() { | |
var func = () => 'I return too'; | |
assert.equal(func(), 'I return too'); | |
}); | |
it('one parameter can be written without parens', () => { | |
var func = p => p + 1; | |
assert.equal(func(23), 24); | |
}); | |
it('many params require parens', () => { | |
var func = (param, param1) => param + param1; | |
assert.equal(func(23, 42), 23+42); | |
}); | |
it('body needs parens to return an object', () => { | |
var func = () => { | |
return {iAm: 'an object'} | |
}; | |
assert.deepEqual(func(), {iAm: 'an object'}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment