Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 
avatar of Tudor Morar

Tudor Morar

Tudor Morar has asked 1 questions and find answers to 3 problems.

Stats

27
EtPoint
2
Vote count
1
questions
3
answers

About

const j= {
    choice1: false,
    choice2: true
};

const map = {
    true: 'default',
    ...(j.choice1 ? {[`${j.choice1}`]: 'choice1'} :{}),
    ...(j.choice2 ? {[`${j.choice2}`]: 'choice2'} :{})
}['true']

console.log(map) // 'choice2'