function replacement(m) { for(var i = 0; i <= m.length; i++){ if (m[i] == ',') { m[i] = 'ererrr'; alert(m[i]) }; } return m; } replacement([1, ',', '2'])