data-to-JSON conversion in JavaScript

Using the JSON.stringify method, you can convert JavaScript arrays and objects to JSON format. Let's look at an example.

Let's say we have an array:

javascriptlet arr = [1, 2, 3, 4, 5, 'a', 'b'];

Let's convert our array to a string:

javascriptlet json = JSON.stringify(arr);
Задание 1

Given the following array:

javascriptlet json = ['user1', 'user2', 'user3', 'user4', 'user5'];

Convert this array to JSON.

Задание 2

Given the following HTML:

html<ul>
  <li>city1</li>
  <li>city2</li>
  <li>city3</li>
  <li>city4</li>
</ul>

Get a list of cities in JSON.

Задание 3

Given the following HTML:

html<table>
  <tr>
    <th>Surname</th>
    <th>Name</th>
  </tr>
  <tr>
    <td>Daniels</td>
    <td>Jack</td>
  </tr>
  <tr>
    <td>Doe</td>
    <td>John</td>
  </tr>
  <tr>
    <td>Green</td>
    <td>Jimmy</td>
  </tr>
</table>

Get the represented JSON data as an object with the keys surname and name.