title: javascript add key to array value lat and lng for google map latlng
body: <p>I have an array that look like these: these are coordinates from an API</p>
  <pre><code>const paths = [
    [22.372081, 114.107877],
    [22.326442, 114.167811],
    [22.284419, 114.159510]
  ];
  </code></pre>
  <p>I need to convert it to something like these: with keys of lat and lng for each row.</p>
  <pre><code>{lat: 22.372081, lng: 114.107877},
  {lat: 22.326442, lng: 114.167811},
  {lat: 22.284419, lng: 114.159510}
  </code></pre>
  <p>I only have this short code but its not working what i wanted.</p>
  <pre><code>const waypts= [];
  const paths = [
    [22.372081, 114.107877],
    [22.326442, 114.167811],
    [22.284419, 114.159510]
  ];
  for(let i = 0; i &lt; paths.length; i++) {
    waypts.push({
      location: new google.maps.LatLng(paths[i]),
      stopover: false,
    });
    console.log(paths[i]);
  }
  console.log(waypts);
  </code></pre>