Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5976ed7

Browse files
authored
Update README.md
1 parent 6c807f0 commit 5976ed7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

‎README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ let drinkTotal = cart.filter(x=> x.name === "Drink")
234234
console.log(`Total Drink Cost $${drinkTotal}`); // Total Drink Cost 14ドル.13
235235
```
236236

237+
<a href="https://codepen.io/Bunlong/pen/yqXbXQ" target="_blank">Edit on Codepen</a>
238+
237239
## Pipelines
238240

239241
A pipeline allows for easy function composition when performing multiple operations on a variable. Since JavaScript lacks a Pipeline operator, a design pattern can be used to accomplish the task.
@@ -245,11 +247,17 @@ const pipe = functions => data => {
245247
data
246248
);
247249
};
250+
248251
let cart = [3.12, 45.15, 11.01];
249252
const addSalesTax = (total, taxRate) => (total * taxRate) + total;
253+
250254
const tally = orders => pipe([
251255
x => x.reduce((total, val) => total + val), // sum the order
252256
x => addSalesTax(x, 0.09),
253257
x => `Order Total = ${x.toFixed(2)}` // convert to text
254-
])(orders); // Order Total = 64.62
258+
])(orders);
259+
260+
console.log(tally(cart)); // Order Total = 64.62
255261
```
262+
263+
<a href="https://codepen.io/Bunlong/pen/qyjmPO" target="_blank">Edit on Codepen</a>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /