Skip to content
Advertisement

how to add and remove number without duplicate in the state object inside the array in Reactjs?

The below code which i’m using to add the data in the state the code is

JavaScript

my State is Given Below

JavaScript

im adding numeric value from 1 to 30 but when i try to add same number it adds to the array i should not add it again please give me solution

Advertisement

Answer

before updating the state perform an evaluation like then assign the days

JavaScript

for deletion

JavaScript
Advertisement