Javascript Algorithms and Data Structures Challenge: Day 2

const o={ a:1, b:3, c:2};
const result={};
const keys= Object.keys(o);
const values= Object.values(o);
const sortedArray=[...values]; // must copy new
sortedArray.sort((a,b)=>a-b);
for (let v of sortedArray){
let i= sortedArray(v);
let index=values.indexOf(v);
let key=keys[index];
result[key]=v;
}
console.log(result)

coder, founder and explorer.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

7 JavaScript Code Practices Your Colleagues Will Love You For

Service Workers in React

Opinionated Redux Setup with Typescript

[JS “1st timers”] Recursion

Connect a Relational DB and Backend with Node.js, Sequelize, PostgreSQL

REACT NEWS : Update in Redux-Observable, GraphQL, Mobile Centre, TC39, Webpack, React Fiber, and…

How to have Better NPM Scripts with Scripty

A Guide to JSON-LD for Beginners

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
FRANK GO

FRANK GO

coder, founder and explorer.

More from Medium

What is try-catch in JavaScript?

How to copy objects in Javascript?

JavaScript Some Key Topics

15 JavaScript array methods you need to know in 2020