Skip to content
Advertisement

How to remove an item in an array in if else statement [closed]

To do:

  • select 0 hr only show 15, 30, 45 minutes select
  • 1,2,3,4 hr show 0,15, 30, 45 minutes

I want to shorthen this if else statement

JavaScript

Use this array to delete or remove from the array when the value 0 is selected

JavaScript

Advertisement

Answer

There are many options how you can delete an element from the array.

Look at the snippet below, there you can find examples with filter, slice and splice array methods for removing items.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement