var a = '5 4 5 Н5 2 4 5 5 4 4 5'.match(/\d/g), avr = a.reduce((a, c) => +a + +c) / a.length; alert(avr)