Answer the question
In order to leave comments, you need to log in
How to output JSON as a valid string?
Unable to complete the task: In the last-bottom field, write the code for the task(x) function that returns JSON as a valid string (which is the result of applying the JSON.stringify function to the object);
The original object must have a love property with a javascript string value, a year property with a numeric value of 2020, and an arg property with an x value.
function task(x) {
let user = {
love: 'javascript',
year: 2020,
arg: x
}
console.log(JSON.stringify(user, null, 2))
}
function task(x) {
let user = {
love: 'javascript',
year: 2020,
arg: x
}
console.log(JSON.stringify(user))
}
I tried these two options, but the task is not counted with the wording "The expected result is NOT produced". Maybe professionals will tell you where the error is or it was necessary to use a different line output than mine. The word "correct" in the assignment is especially confusing ... thanks in advance for the answer ...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question