# Statements as expressions

**URL:** <https://es.discourse.group/t/statements-as-expressions/894>\
**Category:** 💡 Ideas\
**Created:** [July 28, 2021, 3:46am UTC](https://es.discourse.group/t/statements-as-expressions/894 "2021-07-28T03:46:17Z")\
**Posts on this page:** 1\
**Showing post:** 28

<div class="post-metadata">

**Author:** ![theScottyJam](https://yyz2.discourse-cdn.com/free1/user_avatar/es.discourse.group/thescottyjam/32/616_2.png) [@theScottyJam](https://es.discourse.group/u/theScottyJam)\
**Post date:** [August 12, 2021, 1:41pm UTC](https://es.discourse.group/t/statements-as-expressions/894/28 "2021-08-12T13:41:27Z")

</div>

The problem with loops is that, with only a handful of exceptions, they necessitate operating on mutable logic. Many languages get by without them, and I think while operating in an expression context it can be good to not have access to them. Instead, functions such as `.map()`, `.filter()`, and `.reduce()` can be used (though I'm not actually a fan of `.reduce()`). Though, if we think loops are valuable as expressions, I'm open to discussing it.

And yes, `do ... in` is indeed a hazard. I'm currently running with the following syntax instead:

```javascript
const result = (
  with x = getX()
  with y = getY()
  with z = x + y
  do processZ(z)
)

```

---

_[View the full topic](https://es.discourse.group/t/statements-as-expressions/894)._
