---
title: "Discussion on \"fCC - Basic JavaScript: Replace Loops using Recursion\" | Hashnode"
description: "Discussion on \"fCC - Basic JavaScript: Replace Loops using Recursion\". I don't understand this. I got through this exercise using the hints given by fCC but I still don't really get it\nBasic JavaScript: Replace Loops using Recursion\nRecursion is the concept that a function can be expressed in terms of itself. To help un..."
url: "https://hashnode.com/posts/fcc-basic-javascript-replace-loops-using-recursion/5eb1d755352b69972eb69825"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [fCC - Basic JavaScript: Replace Loops using Recursion](https://hashnode.com/post/fcc-basic-javascript-replace-loops-using-recursion?utm_source=hashnode&utm_medium=feed)

I don't understand this. I got through this exercise using the hints given by fCC but I still don't really get it Basic JavaScript: Replace Loops using Recursion Recursion is the concept that a function can be expressed in terms of itself. To help un...

May 5, 2020 · hashnode.com  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[miguelmanalo](https://hashnode.com/@miguelmanalo)

@miguelmanalo

  
[View profile](https://hashnode.com/@miguelmanalo)

## Responses 1

Markdown supported · ⌘↵ to post

[fengxh](https://hashnode.com/@fengxh)

[May 6, 2020](https://hashnode.com/posts/fcc-basic-javascript-replace-loops-using-recursion/5eb1d755352b69972eb69825/comment/5eb23406f89d4c762e707c62)

You can use `reduce` to finish the multiply action.

```
function multiply(arr) {
  if (arr.length <= 0) return 1;
  return arr.reduce((result, number) => {
    return result * number;
  }, 1); 
}
```

Another thing about recursion is tail optimization, it can reduce the usage of call stack to minimize space complexity.
