Skip to content

Instantly share code, notes, and snippets.

@npgenx
Last active April 30, 2022 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npgenx/d6b1c8c338635b39c093a5da74d05747 to your computer and use it in GitHub Desktop.
Save npgenx/d6b1c8c338635b39c093a5da74d05747 to your computer and use it in GitHub Desktop.
js: sort objects using an index array
/**
* @param {number[]} nums
* @param {number} target
* @return {number[]}
*/
const nums = [2, 7, 11, 15, 20], target = 9;
for (const [idx, testnum] of nums.entries()) {
console.log(`id:(${idx}): ${testnum}`);
}
var twoSum = function (nums, target) {
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment