Last active
June 12, 2016 08:53
-
-
Save reneviering/b952c8c6fd3e807ca94b1b390800d3b2 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Challenge 5/79 (arrow functions - basics)
First challenge in the new category »arrow functions«. This was a pretty simple kata, nothing new.