I want to find all keys with the value "age," and swap them. But I don't want to swap every key
{
const comiccharactersswap = Object.entries(comiccharacters).map(
//But only if the value is "age"
if (value == 'age')
([key, value]) => [value, key]
);
You need to put the condition inside the function, not around it.
const comiccharactersswap = Object.entries(comiccharacters).map(
([key, value]) => value == 'age' ? [value, key] : [key, value]
);