Snippet format update
To match the starter (for the migration)
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
### when
|
||||
---
|
||||
title: when
|
||||
tags: function,intermediate
|
||||
---
|
||||
|
||||
Tests a value, `x`, against a predicate function. If `true`, return `fn(x)`. Else, return `x`.
|
||||
|
||||
@ -12,4 +15,4 @@ const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x);
|
||||
const doubleEvenNumbers = when(x => x % 2 === 0, x => x * 2);
|
||||
doubleEvenNumbers(2); // 4
|
||||
doubleEvenNumbers(1); // 1
|
||||
```
|
||||
```
|
||||
Reference in New Issue
Block a user