From 19b397d463ec2c4a9b29d4cb26600cccaf5bc4df Mon Sep 17 00:00:00 2001 From: Kevin Simper Date: Sun, 26 Aug 2018 13:41:54 +0200 Subject: [PATCH] Update cheatsheet with map/forEach examples --- docs/syntax-cheatsheet.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/syntax-cheatsheet.md b/docs/syntax-cheatsheet.md index 31f66d2a9c..82f0446ca0 100644 --- a/docs/syntax-cheatsheet.md +++ b/docs/syntax-cheatsheet.md @@ -149,6 +149,13 @@ Both JavaScript and Reason support currying, but Reason currying is **built-in a | `for (let i = 10; i >= 0; i--) {...}` | `for (i in 10 downto 0) {...}` | | `while (true) {...}` | Same | +## forEach / map + +| JavaScript | Reason | +|------------------------------------------|-------------------------------------------| +|`[1,2,3].forEach(i => { console.log(i) })`|`Array.iter(i => { Js.log(i) }, [|1,2,3|])`| +|`[1,2,3].map(i => { return i + 1 })` |`Array.map(i => i + 1, [|1,2,3|])` | + ## JSX | JavaScript | Reason |