K
K
Kipsy2021-06-17 15:36:45
JavaScript
Kipsy, 2021-06-17 15:36:45

How to change boolean value in localStorage?

Hello. I have such a task. When I click on the button, I write to local.push {isOpen: true}
And when I click again, these records are simply duplicated, but how can I make only 1 record and manipulate it by changing it to true-false?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
WapSter, 2021-06-17
@Kipsi

el.addEventListener('click', () => {
    const value  =  !localStorage.getItem('isOpen')
    localStorage.setItem('isOpen', value)
})

A
Alice, 2021-06-17
@w3bsmes

Hold

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question