jeudi 9 janvier 2020

How to check value of key in Object and use it in if statement? JavaScript

I'am a real beginner and just enthusiast of JavaScript. I need help. I've got problem with code below:

if (newTask.done === false) {
        newTask = doneArray.push({
            id: doneArray.length,
            description: clickedTask.textContent,
            done: false
        });
    } else {
    removeTask = doneArray.splice(newTask.id, 1);
    };

I need to check if my object have false or true value in done key. When new task have false I want to push it to my Array, and if not remove it from my Array. I don't know how to take value of id and use it in if statement. Then change that value in object into true. I don't know, maybe there is much better way to make it work and not deleting whole code. Here is full code: codepen.io

Aucun commentaire:

Enregistrer un commentaire