Can’t assign object to the right instance of the other object [closed]

I’m trying to make to-do app using JS but when I add to-do to one instance of the project then it is also added to the other project,worst part is that when I asign to the one then the task is DOUBLED so instead of adding one task to the current project it is added twice and x4 to previously added project.I know it’s probably problem with my event listeners or how I pass the project instance down my functions but I can’t find a way to fix this.

import { clearElement } from "./clearElement"
import { projectList } from "./projectList";
import { openProject } from "./openProject";
export function displayProjects(){
    const buttonsDiv=document.querySelector(".buttons");
    clearElement(buttonsDiv);
   projectList.forEach((project)=>{
    const projectButton=document.createElement("button");
    projectButton.textContent=project.title;
    projectButton.addEventListener("click",(e)=>openProject(e));
    buttonsDiv.appendChild(projectButton);
   })
   

}
import { titleParagraphContent } from "./titleParagraphContent";
import { showTaskModal } from "./showTaskModal";
import { addNewTask } from "./addNewTask";
import { clearElement } from "./clearElement";
export function displayProject(project){
    const projectHeader=document.querySelector(".project-header");
    const addTaskButton=document.createElement("button");
    const addTaskButtonDiv=document.querySelector(".Task-button");

    clearElement(addTaskButtonDiv);
    projectHeader.textContent=titleParagraphContent;
    addTaskButton.classList.add("add-task");
    addTaskButton.textContent="+";
    addTaskButton.addEventListener("click",showTaskModal);
    addTaskButtonDiv.appendChild(addTaskButton);

    const submitTaskButton=document.querySelector("#add-new-task");
    submitTaskButton.removeEventListener("click",addNewTask);
    submitTaskButton.addEventListener("click",(e)=>addNewTask(e,project));

}
import { projectList } from "./projectList";
import { clearElement } from "./clearElement";
import { displayProject } from "./displayProject";
import { displayTasks } from "./displayTasks";
export function openProject(e){

    const button=e.target;
    const projectName=button.textContent;
    const titleDiv=document.querySelector(".title");

    let index=_.findIndex(projectList,function (project){ return project.title===projectName});
    let projectToDisplay=projectList[index];
    clearElement(titleDiv);
    titleDiv.textContent=projectName;
    displayProject(projectToDisplay);
    displayTasks(projectToDisplay);



}
import { displayTasks } from "./displayTasks";
import { Task } from "./task";
export function addNewTask(e,project){

    e.preventDefault();
    let title=document.getElementById("ftitle").value;
    let description=document.getElementById("fdesc").value;
    let dueDate=document.getElementById("fdate").value;
    let priority=document.getElementById("fpriority").value;

    let task=new Task(title,description,dueDate,priority);
    project.addToProject(task);
    displayTasks(project);
    


}
import { Project } from "./project"
import { projectList } from "./projectList";
import { displayProjects } from "./displayProjects";
export function addNewProject(title){
    const project=new Project(title);
    projectList.push(project);
    
    displayProjects();


}
import { clearElement } from "./clearElement";

export function displayTasks(project){
    const taskList=document.createElement("ul");
    const tasksDiv=document.querySelector(".tasks");
    clearElement(tasksDiv);
    clearElement(taskList);
    project.projectTasks.forEach(element => {
        const li=document.createElement("li")
        const liContext=element.title;
        li.textContent=liContext;
        taskList.appendChild(li);
    });
    tasksDiv.appendChild(taskList);

}
export class Task{
    constructor(title,description,dueDate,priority){
        this.title=title;
        this.description=description;
        this.dueDate=dueDate;
        this.priority=priority;
        this.isDone=false;
    }
    setDone(){
        this.isDone=true;
        
    }
    
}
export class Project{
    constructor(title){
        this.title=title;
        this.projectTasks=[];
    }
    addToProject(task){
        this.projectTasks.push(task);
    }
   
}

I’ve tried to clearing HTLM elements but it didn’t work,when I unsubscribed to the event,1 additional copy stopped apearing but after another task adition it was like before.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật