Travis build: 1737

This commit is contained in:
30secondsofcode
2020-01-30 19:37:05 +00:00
parent 13eda7be52
commit 0a709f6e99
9 changed files with 72 additions and 75 deletions

View File

@ -10,14 +10,13 @@ Determine the `symbol` to be either `?` or `&` based on the `length` of `querySt
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 = queryString.length === 0 ? '?' : '&';
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : '';
return queryString;
}, '')
const symbol = queryString.length === 0 ? '?' : '&';
queryString += typeof val === 'string' ? `${symbol}${key}=${val}` : '';
return queryString;
}, '')
: '';
};
```