Skip to content
Advertisement

assign object keys dynamically using jquery or vanilla js [closed]

I have an empty object in which I would like to assign data dynamically

Expected results

JavaScript

What I have tried so far.

JavaScript

On console I see

JavaScript

but the expected result should be

JavaScript

What do I need to change to get what I want ?

Advertisement

Answer

userData[getBtn] = inputValue;

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement