JSON.stringify (Basic)
Difficulty: medium
Implement a function jsonStringify, similar to JSON.stringify, that converts a JavaScript value into a JSON string.
For this basic version, you only need to handle JSON-serializable values:
- Booleans
- Numbers
- Null
- Arrays
- Plain Objects
- Strings
Ignore the second and third optional parameters of the original API.
Example
jsonStringify({ foo: 'bar' }); // '{"foo":"bar"}'
jsonStringify([1, 2, "three"]); // '[1,2,"three"]'