Hi everyone!
I’m trying to get some help with a piece of JavaScript code I’m using in Make. The code below works, but it only returns a single output with all the values on the same line. I’d like to have multiple usable variables (one output for formattedPrenom
, another for formattedNom
, and a third one for utm_variable
).
Here’s the code I’m using:
javascript
function removeAccents(str) { return str.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); } function formatNamePart(namePart) { return namePart .replace(/[^a-zA-ZÀ-ÿ\s-]/g, '') .trim() .split(' ') .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) .join(' '); } function formatForUrl(namePart) { return removeAccents(namePart) .toLowerCase() .replace(/\s+/g, '-'); } let first_name = inputData.first_name; let last_name = inputData.last_name; let formattedPrenom = formatNamePart(first_name); let formattedNom = formatNamePart(last_name); let utm_variable = `${formatForUrl(formattedPrenom)}.${formatForUrl(formattedNom)}`; // Retourner les variables comme une liste de valeurs return [ formattedPrenom, formattedNom, utm_variable ];
However, I’m only getting one output with all the values together on the same line. What I’d like is to have separate outputs so I can use formattedPrenom
, formattedNom
, and utm_variable
as individual variables in my workflow.
Can you help me?
Thanks a lot for your help!