const fullName = () => {
let fullName = "";
fullName += billing?.['first_name'] + " ";
fullName += billing?.['last_name'];
return fullName;
};
...
formData.append('name', fullName);
const makeOrderList = str =>
Object.fromEntries(Array.from(
str.matchAll(/(\d+) ([^,]+)/g),
n => [ n[2].replace(/ /g, '_'), +n[1] ]
));
const makeOrderList = str => str
.split(', ')
.map(n => [ n.split(' ').slice(1).join('_'), parseInt(n) ])
.filter(n => !Number.isNaN(n[1]))
.reduce((acc, n) => (acc[n[0]] = n[1], acc), {});
for (var i = 0, j = isNaN(test) ? 5 : test; i < j; i++)
"undefined"
не будет. Будет ошибка. Для этого можно сделать:try {
j = test
} catch(e) {
j = 5;
}