I'm trying to create a function to add a new property with no value yet, into an empty object, but it keeps returning undefined
below is the code i've written
const obj1={};
function addData (object,prop1,value){
object[prop1]=value;
};
console.log(addData(obj1,"Person 1",""))
i've tried writting this code outside the function and it works
obj1["Person 1"]="";
obj1["Person 2"]="";
it will return as below
{'Person 1' : '' , 'Person 2' : ''}
Why does the function return undefined whereas writing it manually works?