I am attempting to get a specific value by supplying the literal key in a javascript object. In the image below you see that "filter" is equal to "Approved". This is coming from reimb_status_description in the image below.
Line 6 of the code is where I assign filter to the value.
const filter = Object.values(jsonData[i]["reimb_status_description"]).join("");
What I do not understand is that if I did not end with .join(""), filter would read as "A,p,p,r,o,v,e,d" which is apparently an array of the letters. Could someone please help me understand why the result is an array instead of just a string? Also, is there a better method of extracting the data I am looking for?
function PopulateReimbursementTable(jsonData, appliedFilter)
{
ClearReimbursementTable();
for(var i = 0; i < jsonData.length; i++)
{
const tr = document.createElement("tr");
const entries = Object.entries(jsonData[i])
const filter = Object.values(jsonData[i]["reimb_status_description"]).join("");
console.log("filter: " + filter)
for(const [key, property] of entries)
{
if(fields.includes(key)){
console.log(key + "\t" + property);
const td = document.createElement("td");
if(key == "reimb_date_submitted" || key == "reimb_date_resolved"){
if(property == null)
{
td.innerHTML = "tbd";
}else{
var d = new Date(property);
let formatted_date = appendLeadingZeroes((d.getMonth() + 1)) + "-" + appendLeadingZeroes(d.getDate()) + "-" + d.getFullYear();
//console.log(formatted_date)
td.innerHTML = formatted_date;
}
} else if(key == 'reimb_amount'){
if(property === null || property === undefined)
{
td.innerHTML = "tbd";
}else{
td.innerHTML = formatter.format(property);
}
}
else
{
if(property === null || property === undefined)
{
td.innerHTML = "tbd";
}else{
td.innerHTML = property;
}
}
if(fields.includes(key))
{
tr.appendChild(td);
}
}
}
if(appliedFilter == "All"){
reimbTableBody.appendChild(tr);
}
else if(filter == appliedFilter){
reimbTableBody.appendChild(tr);
}
}
}

jsonData[i]["reimb_status_description"]is a string, so if you doObject.valueson it, it would be treated as an array and thus you get the values of said array.