Javascript Challenges


This challenge will help you to understand how JSON object works. Take a look to the following code:

var parent = {
    name: 'peter',
    surname: 'doe'
var parentStringified = JSON.stringify( parent );

After execute the previous code we execute the following statement and the result is true.

console.log( parentStringified === '{ "name": "peter", "surname": "doe" }');



Write the code needed to get the expected result without changing the values of and obj.surname values:

var obj = { name: 'john', surname: 'doe' }; // Write the code to get '{ "name": "james", "surname": "sullivan" }' // when the next statement is executed. var result = JSON.stringify( obj );