JSFiddle - React, Tailwind, and code Playground
by graphettion
JavaScript
'use strict';
let body = document.body,
homies = '';
const parseJSON = '{"name": "Codye Watson"}',
stringifyJSON = {
"name": "Codye Watson"
},
sampleOfJSON = {
"name": "Codye Watson",
"born": "January 22, 1986",
"chilren": ["Aria Rose"],
"wife": "Lauren Watson",
"homies": [
"jahan",
"innovati",
"shok"
]
};
function render(data) {
body.innerHTML += '<p>' + data + '</p>';
}
//Get a value
render(stringifyJSON.name);
//Parse JSON (covert a string into JSON)
render(JSON.parse(parseJSON).name);
//Stringify JSON (convert JSON into a string)
render(JSON.stringify(stringifyJSON["name"]).replace(/\"/g, ''));
//Find each item in "homies" in sampleOfJSON
sampleOfJSON.homies.forEach((item) => {
return render(item + ' ');
});