Skip to content

Instantly share code, notes, and snippets.

@danielmconrad
Created May 20, 2015 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielmconrad/085dc402dc4b186a8641 to your computer and use it in GitHub Desktop.
Save danielmconrad/085dc402dc4b186a8641 to your computer and use it in GitHub Desktop.
Challenge: myJSON.stringify
//Q. Create an object, myJSON, with one function, `stringify` that will take one parameter and stringify it like `JSON.stringify` does.
//Object types can be:
// Object
// Array
// Number
// String
// Boolean
var myJSON, thingToStringify;
myJSON.stringify = function(input){
// Your code goes here
};
//thingToStringify = 1;
//thingToStringify = ‘one’;
//thingToStringify = ‘1’;
//thingToStringify = [1];
//thingToStringify = {one: 1};
//thingToStringify = {one: ‘1’};
//thingToStringify = {one: [‘one’]};
//thingToStringify = {one: {won: 1}};
output = myJSON.stringify(thingToStringify);
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment