Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add task solution #426

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

RomanenkoStud
Copy link

Copy link

@polosanya polosanya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start! Let's improve the game a bit

  1. Game doesn't work correctly. Numbers are not combined if they should move before.
    Check how it works on working example
    2048-bug
  2. I can press any button and add a number
    image
  3. There should be a chance for "4" to appear at start

@RomanenkoStud RomanenkoStud marked this pull request as draft July 31, 2023 09:08
Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍
Let's improve your code

this.message.setMessage(this.MESSAGES.START);
}

load() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The load() method returns this without doing anything, which seems unnecessary. If this is not being used, consider removing it.

addTile(value) {
const emptyCells = [];

for (let row = 0; row < this.cells.length; row++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using 'forEach' or 'map' instead of the 'for' loop for better readability and performance. You could use a nested 'forEach' loop to iterate over the 2D 'cells' array.

}

hasAvailableMoves() {
for (let row = 0; row < this.cells.length; row++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using 'forEach' or 'map' instead of the 'for' loop for better readability and performance. You could use a nested 'forEach' loop to iterate over the 2D 'cells' array.


const rows = element.querySelectorAll('.field-row');

for (let i = 0; i < rows.length; i++) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using 'forEach' or 'map' instead of the 'for' loop for better readability and performance. For instance, you can refactor this part like 'rows.forEach((row, i) => {...})'.

Copy link

@polosanya polosanya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Sometimes random number appears on move. Please make sure that only 2 or 4 appears
    2048-random
  2. Also, "4" still never appears at start
    image

@RomanenkoStud
Copy link
Author

sorry, i thought for some reason that any number can appear)

@RomanenkoStud RomanenkoStud marked this pull request as ready for review July 31, 2023 18:13
Copy link

@volodymyr-soltys97 volodymyr-soltys97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants