add logic for habit done

This commit is contained in:
2025-11-06 22:40:56 +03:00
parent 6c71321076
commit abed02fdc2
2 changed files with 30 additions and 7 deletions

View File

@@ -16,7 +16,7 @@ const HabitManager = {
HabitManager.createHabit = function (name, description, targetCount = 1) {
const habit = {
id: Math.random(),
id: Math.floor(Math.random() * 100000, 10000),
name: name,
description: description,
targetCount: targetCount,
@@ -31,6 +31,7 @@ HabitManager.createHabit = function (name, description, targetCount = 1) {
}
HabitManager.markHabitDone = function (habitId) {
console.log(this.habits);
const habit = this.habits.find(h => h.id === habitId);
if (!habit) {