made with esnextbin
Created
June 1, 2016 15:27
-
-
Save TN1ck/8bac540cd60b7a9da6402a03b1c6c920 to your computer and use it in GitHub Desktop.
esnextbin sketch
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ESNextbin Sketch</title> | |
<!-- put additional styles and scripts here --> | |
</head> | |
<body> | |
<!-- put markup and other contents here --> | |
</body> | |
</html> |
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
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
const _ = require('lodash'); | |
const test = ['test1']; | |
const test2 = ['test1', 'test2']; | |
const test3 = ['test1', 'test2', 'test3']; | |
const humanizeList = (array) => { | |
if (array.length <= 1) { | |
return array.join(''); | |
} | |
const interposeWith = _.fill(Array(array.length - 2), ', ').concat(' und '); | |
return _(array).zip(interposeWith).flatten().value().join(''); | |
}; | |
console.log(humanizeList(test)); | |
console.log(humanizeList(test2)); | |
console.log(humanizeList(test3)); |
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
{ | |
"name": "esnextbin-sketch", | |
"version": "0.0.0", | |
"dependencies": { | |
"lodash": "4.13.1" | |
} | |
} |
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
'use strict'; | |
// write ES2015 code and import modules from npm | |
// and then press "Execute" to run your program | |
var _ = require('lodash'); | |
var test = ['test1']; | |
var test2 = ['test1', 'test2']; | |
var test3 = ['test1', 'test2', 'test3']; | |
var humanizeList = function humanizeList(array) { | |
if (array.length <= 1) { | |
return array.join(''); | |
} | |
var interposeWith = _.fill(Array(array.length - 2), ', ').concat(' und '); | |
return _(array).zip(interposeWith).flatten().value().join(''); | |
}; | |
console.log(humanizeList(test)); | |
console.log(humanizeList(test2)); | |
console.log(humanizeList(test3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment