Here is a concise solution that I would suggest:
element.nome.split('').some(b => b.match(/\d/)) ? element.nome.slice(0,-2) : element.nome
To begin, we split the string using the split method, resulting in an array of characters:
"test123".Split('');
// produces
let splitString = ['t','e','s','t','1','2','3'];
We can then apply the "some" function on the new array. This function returns true if any of the conditions are met.
In this case, we use a regular expression (RegExp), /\d/, which signifies "contains a digit". This allows us to filter out the digits.
// For our example, match will return true for 1, 2, and 3, causing some to return true
var containsDigit = splitString.some(s => s.match(/\d/))
Next, we utilize a Ternary operator. If the condition is true, we return "element.nome.slice(0,-2)", otherwise we return the original "element.nome".
{nome: containsDigit ? true : false}
When applied to your specific scenario:
this.aux3.forEach(element => {
this.novasColecoes.push({
"produtos": element.produtos,
"nome": element.nome.split('').some(n => n.match(/\d/)) ? element.nome.slice(0,-2) : element.nome,
"referencia": element.referencia,
"selecionado": false
});
})