arr.filter(n => n % 10 === 4)
// или
arr.filter(n => ''.endsWith.call(n, 4))
// или
arr.filter(n => `${n}`.slice(-1) === '4')
// или
arr.filter(n => /4$/.test(n))
// или
(`${arr}`.match(/\d*4(?=\D|$)/g) || []).map(Number)
int n = 4;
int numbers[n] = {54, 3, 25, 47};
for (int i = 0; i < n; i++) {
if (numbers[i] % 10 == 4) {
cout << numbers[i] << endl;
}
}