Created
January 15, 2019 05:35
-
-
Save OlivierJM/e4cbe69e64d65dadb23fc25f13645110 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/kuvaraw
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"> | |
| <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> |
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
| // 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