Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

uniqSort

const uniqSort = function (arr) {
  const cache = {};
  const result = [];

  for (let i = 0; i < arr.length; i++) {
    if (!cache[arr[i]]) {
      result.push(arr[i]);
      cache[arr[i]] = true;
    }
  }
  return result.sort((a, b) => a - b);
};

console.log(uniqSort([4, 2, 2, 3, 2, 2, 2]));
Comment

PREVIOUS NEXT
Code Example
Javascript :: node.js core modules 
Javascript :: Iterating over a TypedArray 
Javascript :: reduceat 
Javascript :: online javascript coding test 
Javascript :: js sol 
Javascript :: nodejs express use streams 
Javascript :: go-gitea/gitea 
Javascript :: react native getting old navigation parameter 
Javascript :: jacascript loop array 
Javascript :: Access the list of valid values for an Enum field in a MongoDb Mongoose Schema 
Javascript :: register js in viewyii2 
Javascript :: angular detect navigation change 
Javascript :: createSearchParams 
Javascript :: using nodejs cart price calculation 
Javascript :: how to get html paramater in js 
Javascript :: chrome extension get current tab 
Javascript :: Node-Red: 2Outputs 
Javascript :: trigger many url calls JS 
Javascript :: node parse markdown files with frontmatter 
Javascript :: downlaod file from website raect 
Javascript :: Return the N-th value of the Fibonacci sequence 
Javascript :: Implementing cascades in mongoose 
Javascript :: Here is an example of loading a series of middleware functions at a mount point, with a mount path. It illustrates a middleware sub-stack that prints request info for any type of HTTP request to the /user/:id path. 
Javascript :: Get physical path in javascript 
Javascript :: write a program to print patter usign recursion in javascript 
Javascript :: Changing Async/Await to Promises.all to Speed Up API Calls in Node.JS 
Javascript :: node javascript retry promise.all 
Javascript :: Example of Nullish coalescing assignment operator in es12 
Javascript :: ngFor fake 
Javascript :: javascript string get numbers 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =