---
title: "Discussion on \"Write a javascript program to extract the common elements and sort them in an ascending order.\" | Hashnode"
description: "Discussion on \"Write a javascript program to extract the common elements and sort them in an ascending order.\". let arr = [1,2,2,4,5,6,6,7,7]\nlet res = arr.filter((item, index)=>arr.indexOf(item) !== index).sort((a,b)=>a-b)\nconsole.log(res)"
url: "https://hashnode.com/posts/write-a-javascript-program-to-extract-the-common-elements-and-sort-them-in-an-ascending-order/67ee6c53b3a76c3d57f70cf5"
---

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

Discussion

# [Write a javascript program to extract the common elements and sort them in an ascending order.](https://reactonme.hashnode.dev/write-a-javascript-program-to-extract-the-common-elements-and-sort-them-in-an-ascending-order?utm_source=hashnode&utm_medium=feed)

let arr = \[1,2,2,4,5,6,6,7,7\] let res = arr.filter((item, index)=>arr.indexOf(item) !== index).sort((a,b)=>a-b) console.log(res)

Apr 3, 2025 · 1 min read · reactonme.hashnode.dev  
Read the article

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

## 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.
