javascript foreach return new array