-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
base: master
Are you sure you want to change the base?
add task solution #426
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
src/scripts/Game.js
Outdated
this.message.setMessage(this.MESSAGES.START); | ||
} | ||
|
||
load() { |
There was a problem hiding this comment.
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.
src/scripts/Field.js
Outdated
addTile(value) { | ||
const emptyCells = []; | ||
|
||
for (let row = 0; row < this.cells.length; row++) { |
There was a problem hiding this comment.
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.
src/scripts/Field.js
Outdated
} | ||
|
||
hasAvailableMoves() { | ||
for (let row = 0; row < this.cells.length; row++) { |
There was a problem hiding this comment.
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.
src/scripts/Field.js
Outdated
|
||
const rows = element.querySelectorAll('.field-row'); | ||
|
||
for (let i = 0; i < rows.length; i++) { |
There was a problem hiding this comment.
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) => {...})'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i thought for some reason that any number can appear) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job 👍
DEMO LINK