Travis build: 1516

This commit is contained in:
30secondsofcode
2019-10-18 06:34:35 +00:00
parent 21299045b8
commit cb26e0ba49
14 changed files with 159 additions and 152 deletions

View File

@ -10,19 +10,17 @@ Determine the `symbol` to be either `?` or `&` based on the `index` and concaten
Return the `queryString` or an empty string when the `queryParameters` are falsy.
```js
const objectToQueryString = queryParameters => {
return queryParameters
? Object.entries(queryParameters).reduce((queryString, [key, val], index) => {
const symbol = index === 0 ? '?' : '&';
queryString += (typeof val === 'string') ? `${symbol}${key}=${val}` : '';
return queryString;
}, '')
const symbol = index === 0 ? '?' : '&';
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : '';
return queryString;
}, '')
: '';
};
```
```js
objectToQueryString({page: '1', size: '2kg', key: undefined}); // '?page=1&size=2kg'
objectToQueryString({ page: '1', size: '2kg', key: undefined }); // '?page=1&size=2kg'
```