-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringify.js
More file actions
34 lines (28 loc) · 755 Bytes
/
stringify.js
File metadata and controls
34 lines (28 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// TODO: JSON.stringify
// The JSON.stringify() function converts a JavaScript object or value to a JSON string:
let users = [
{
id: 1,
first_name: 'Robert',
last_name: 'Schwartz',
email: 'rob23@gmail.com',
},
{
id: 2,
first_name: 'Lucy',
last_name: 'Ballmer',
email: 'lucyb56@gmail.com',
},
{
id: 3,
first_name: 'Anna',
last_name: 'Smith',
email: 'annasmith23@gmail.com',
},
];
let data = JSON.stringify(users);
console.log(typeof data);
console.log(typeof users);
console.log(data);
console.log(users);
// In the example, we have an array of users. We transform the array into a JSON string with the JSON.stringify() function.