I want the shop ID to be included in the array and displayed in the string \A/shop/${shopId*array0}/$|\A/shop/${shopId*array1}/$|\A/shop/${shopId*array0}/$...
const shopId=[263,966,5439,5478,5613,5368,169,1499,42382,4807,4808,5244];
salonId.forEach((salonId)=>{
console.log(`\\A/shop/${shopId}/$`);
});
I would like to use a "|" (pipe) to connect the string from the first array after executing it with each as above, but I don't know how to do it.
Can someone teach me?
If you want forEach
, you will need another array containing the results of the action in forEach
.In the first place, map()
would be more appropriate.
shopId.map(s=>`\\A/shop/${s}/$`).join('|');
© 2024 OneMinuteCode. All rights reserved.