Skip to content

Exercise: JSON.stringify()

Prompt

Implement stringifyJSON to mimic JSON.stringifiy()
The JSON.stringify() method converts a JavaScript object or value to a JSON string
Read more in the
MDN docs
Bonus: Implement the optional replacer functionality!
function stringifyJSON(obj) {
// implement here
}

// These two logs should match:
console.log(stringifyJSON({ x: 5, y: 6, z: [1, true, {'hi': 'bye'}, function(){}] }));

console.log(JSON.stringify({ x: 5, y: 6, z: [1, true, {'hi': 'bye'}, function(){}] }));
Copy and paste the starter code above or clone the below to get started!

Code Here

This embedded link can't be shown.



Next 👉


©2021 for
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.