JSFiddle - React, Tailwind, and code Playground

by Shrawan Lakhe

HTML

<input type='text' id='txtName' />
<button id='btnAddProperty'>Add</button>

JavaScript

var obj = {
"1":"aa",
"2":"bb"
};

var noOfItems=Object.keys(obj).length;
$('#btnAddProperty').on('click',function(){
    noOfItems++;
    obj[noOfItems]=$.trim($('#txtName').val());
    console.log(obj);
});