I have a very weird task to complete. Basically I have object like this:
{
a: 'abc',
key1: 'someKeyOne',
key2: 'someKeyTwo',
value1: 'someValueOne',
value2: 'someValueTwo',
yetAnotherProperty: 'dadjsa'
}
My goal is to create new object from properties that are keys and values so the new one will be:
{
someKeyOne: 'someValueOne',
someKeyTwo: 'someValueTwo',
}
In object there can be many "non key" or "non value" properties, but keyX
and valueX
are always in the same amount. I tried to use Object.keys
and check if key includes
key, and then value but I couldn't create new object from it...
Any advice?