Foreach Javascript Array Filter Function