In my project I have a form for messages the user can send to me, when the validation fail I need to display the errors for him, but the errors the I get from the backend is an object of arrays and I extracted the values and concatenated it in one string by this
let errors = Object.values(data);
let errorsMarkup = ""
for (let i = 0; i < errors.length; i++) {
errorsMarkup += `${errors[i]}`;
}
now the string will be sentences that shows the errors separated by dots, I need it to be separated by break lines to show the user the errors one by line so I made this
errorsMarkup = errorsMarkup.replace(/\./g,'<br>');
and I call the sweet alert to show the errorsMarkup
Swal.fire({
icon: 'error',
title: 'Oops...',
text: errorsMarkup
});
but this is what I get