Skip to content

Instantly share code, notes, and snippets.

@OlivierJM
Created January 15, 2019 05:35
Show Gist options
  • Select an option

  • Save OlivierJM/e4cbe69e64d65dadb23fc25f13645110 to your computer and use it in GitHub Desktop.

Select an option

Save OlivierJM/e4cbe69e64d65dadb23fc25f13645110 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kuvaraw
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/expect/1.20.2/expect.js"></script>
</head>
<body>
<script id="jsbin-javascript">
// Count how many digits there are in the following
// sentence, using functional composition
'use strict';
var sentence = 'PechaKucha is a presentation style in which 20 slides are shown for 20 seconds each (6 minutes and 40 seconds in total).';
// const numbersInString = R.pipe(
// R.split(''),
// R.map(parseInt),
// R.filter(Number.isInteger),
// R.length,
// );
var numbersInString = R.compose(R.length, R.filter(Number.isInteger), R.map(parseInt), R.split(''));
expect(numbersInString(sentence)).toBe(7);
console.log('If you see this printed in the console, the test passed!');
</script>
<script id="jsbin-source-javascript" type="text/javascript">// Count how many digits there are in the following
// sentence, using functional composition
const sentence = 'PechaKucha is a presentation style in which 20 slides are shown for 20 seconds each (6 minutes and 40 seconds in total).';
// const numbersInString = R.pipe(
// R.split(''),
// R.map(parseInt),
// R.filter(Number.isInteger),
// R.length,
// );
const numbersInString = R.compose(R.length, R.filter(Number.isInteger), R.map(parseInt), R.split(''))
expect(numbersInString(sentence)).toBe(7);
console.log('If you see this printed in the console, the test passed!');</script></body>
</html>
// Count how many digits there are in the following
// sentence, using functional composition
'use strict';
var sentence = 'PechaKucha is a presentation style in which 20 slides are shown for 20 seconds each (6 minutes and 40 seconds in total).';
// const numbersInString = R.pipe(
// R.split(''),
// R.map(parseInt),
// R.filter(Number.isInteger),
// R.length,
// );
var numbersInString = R.compose(R.length, R.filter(Number.isInteger), R.map(parseInt), R.split(''));
expect(numbersInString(sentence)).toBe(7);
console.log('If you see this printed in the console, the test passed!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment