Skip to content

[Refactor] Improve the logic of script.js #6622

@castorNova2

Description

@castorNova2

Description

In the UI initialization script responsible for handling beginner/advanced mode, the current implementation uses innerHTML for updating icons and var for variable declarations and used redundant mode check for null.

Expected Behavior

  • DOM updates should use textContent instead of innerHTML
  • Variables should use const and let instead of var

Current Behavior

UI updates use:

modeIcon.innerHTML = "star";

Uses var for variable declarations

Proposed Changes

Replace innerHTML with textContent:

modeIcon.textContent = "star";

Replace var with const / let

Benefits

Improves performance by avoiding unnecessary HTML parsing
Reduces the risk of HTML injection
Aligns with modern JavaScript best practices

Checklist

  • I have read and followed the project's code of conduct.
  • I have searched for similar issues before creating this one.
  • I have provided all the necessary information to understand and reproduce the issue.
  • I am willing to contribute to the resolution of this issue.

Thank you for contributing to our project! We appreciate your help in improving it.

📚 See contributing instructions.

🙋🏾🙋🏼 Questions: Community Matrix Server.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions