Danieldotcomcoder / To-do-List

A simple TO-DO-LIST where you can Add, Remove tasks, and also you can mark tasks as completed and clear all completed tasks.
2 stars 0 forks source link

DRY, KISS, and YAGNI #6

Open Danieldotcomcoder opened 3 years ago

Danieldotcomcoder commented 3 years ago
    itemlist.innerHTML = `
    <input type='checkbox' class='check-box'>
  <h3>${todo}</h3>
  <img src='${menu}' class='edit-btn'>
  <img src='${deletebtn}' class='delete-btn'>`;
    list.appendChild(itemlist);
  }

To avoid repetition you can assign the inner html to a const and use the const instead of repeating the innerhtml code over and over again.

Danieldotcomcoder commented 3 years ago

https://github.com/Danieldotcomcoder/TO-DO-LIST/blob/6e9dfef4282df6b18a9f5c8f0924c6e5b12a4441/src/managelists.js#L35 https://github.com/Danieldotcomcoder/TO-DO-LIST/blob/6e9dfef4282df6b18a9f5c8f0924c6e5b12a4441/src/managelists.js#L89 https://github.com/Danieldotcomcoder/TO-DO-LIST/blob/6e9dfef4282df6b18a9f5c8f0924c6e5b12a4441/src/managelists.js#L106 https://github.com/Danieldotcomcoder/TO-DO-LIST/blob/6e9dfef4282df6b18a9f5c8f0924c6e5b12a4441/src/managelists.js#L124 https://github.com/Danieldotcomcoder/TO-DO-LIST/blob/6e9dfef4282df6b18a9f5c8f0924c6e5b12a4441/src/managelists.js#L141

You can assign the localstorage.setItem function to a const instead of repeating many times