Wrong method

Report a typo

The backend developer from Google is at his wit's end trying to understand what is wrong with his code. He wanted to create 3 routes: one for Gmail, one for images, and one for docs with the same base URL (https://google.com). In fact, he chose the wrong querystring method. What he should have used instead? Just specify the name of the method.

Here's his code:

const { parse } = require('node:querystring');

const routes = [];

const baseUrl = 'https://google.com/';

const routesQueries = [{
    service: 'gmail',
    auth: true
}, {
    service: 'img',
    lang: 'ru'
}, {
    service: 'docs',
    create: true
}];

routesQueries.map(q => routes.push(baseUrl + "?" + parse(q)));

console.log(routes);

And this is the expected output:

[
  'https://google.com/?service=gmail&auth=true',
  'https://google.com/?service=img&lang=ru',
  'https://google.com/?service=docs&create=true'
]
Enter a short text
___

Create a free account to access the full topic