AniUI Academy
easy+150 XPPractice

Omit keys from an object

Before logging a request body or writing a record to analytics, you want everything except a handful of fields. Naming what to remove is often shorter and safer than naming what to keep.

Implement omit(source, keys). source is a plain object and keys is an array of property names to drop. Return a new object holding every own property of source whose name is not in keys. The remaining keys keep the relative order they had in source. Names in keys that source does not have are simply ignored. Never modify source.

What it has to do

  • Return a new object without the listed keys.
  • Keep the remaining keys in the same relative order as in source.
  • Ignore listed keys that source does not have.
  • Return {} when source is empty.
  • Do not mutate source.

Your workspace

Try it yourself
Loading playground...

Ready to check it?

5 tests run against your code, right here in your browser. Sign in to claim the XP when you pass.

AI Crack & Solution Assist

Stuck? Get instant AI hints or break down the optimal solution.

Stuck? The javascript course covers everything this challenge needs.