change a string based on array length

You can generate the query params using a for loop.

let baseUrl = '/cliente/porsegmento';
let queryParams = '?';
for(let i =0;i<segmentId.length; i++) {
    if(i>0) {  queryParams += '&'; }
    queryParams = `${queryParams}idsSegmentN1=${segmentId[i]}`;
url = baseUrl + queryParams;

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top