I have a JavaScript object that contains terms and definitions. I want to create a function that displays/prints the key, value pairs on a webpage.
For example:
let dict = {
term1: "definition",
term2: "definition",
term3: "definition",
term4: "definition"
}
Ideal output:
term1: definition
term2: definition
term3: definition
term4: definition
I am currently using this code:
function viewAll()
{
var json = JSON.stringify(dict,null,3);
document.getElementById("output").innerText = json;
}
which outputs:
{
term1: "definition",
term2: "definition",
term3: "definition",
term4: "definition"
}
This is okay, but I'd like to remove the special characters ({",
)