---
title: "Discussion on \"Write a javascript code to flatten the given array without using flattened function.\" | Hashnode"
description: "Discussion on \"Write a javascript code to flatten the given array without using flattened function.\". function flattenArray(arr){ let flattened = []; function flatten(ArrElem){ for(let i=0;i<ArrElem.length; i++){ if(Array.isArray(ArrElem[i])){ flatten(ArrElem[i]) } else{ flattened.push(ArrElem[i]) } } } flatten(arr) return flattened }\nlet arr = [1, 2..."
url: "https://hashnode.com/posts/write-a-javascript-code-to-flatten-the-given-array-without-using-flattened-function/654731e7268d123e05aad0e7"
---

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

Discussion

# [Write a javascript code to flatten the given array without using flattened function.](https://reactonme.hashnode.dev/write-a-javascript-code-to-flatten-the-given-array-without-using-flattened-function?utm_source=hashnode&utm_medium=feed)

function flattenArray(arr){ let flattened = \[\]; function flatten(ArrElem){ for(let i=0;i<ArrElem.length; i++){ if(Array.isArray(ArrElem\[i\])){ flatten(ArrElem\[i\]) } else{ flattened.push(ArrElem\[i\]) } } } flatten(arr) return flattened } let arr = \[1, 2...

Nov 5, 2023 · 1 min read · reactonme.hashnode.dev  
Read the article

## Written by

[Murali Chowhan](https://hashnode.com/@Chowhan)

@Chowhan · Hyderabad

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

Senior Software Developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
