Skip to content

Uses a non const variable to illustrate the assignment in equality check #40442

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

Merged
merged 2 commits into from
Jul 20, 2025

Conversation

himanshugarg
Copy link
Contributor

Description

The assignment check used a const variable. Changed to one that used let

Motivation

  1. Low hanging 🥭
  2. I want to publicly demonstrate my own skills to improve my chances of getting a job.

Additional details

Thanks @Goal-max for reporting

Related issues and pull requests

Fixes #39332

@himanshugarg himanshugarg requested a review from a team as a code owner July 19, 2025 11:04
@himanshugarg himanshugarg requested review from hamishwillee and removed request for a team July 19, 2025 11:04
@github-actions github-actions bot added Content:Learn Learning area docs size/s [PR only] 6-50 LoC changed labels Jul 19, 2025
Copy link
Contributor

github-actions bot commented Jul 19, 2025

Preview URLs

(comment last updated: 2025-07-19 11:23:43)

```

the test would always return `true`, causing the program to report that the game has been won. Be careful!
the test would always return `true`, causing the program to `setGameOver()` after the first wrong guess. Be careful!
Copy link
Member

Choose a reason for hiding this comment

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

Wrong; it would throw an error instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @Josh-Cena for reviewing. I am unable to reproduce the error (FF 128). Could you please share the message/screenshot?
image

Copy link
Member

Choose a reason for hiding this comment

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

Did you intend to change const guessCount to let guessCount? Because that's not reflected in your PR. If you don't change that (I would prefer if you don't), then this line would throw an error instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file references the code from here which has let guessCount already. userGuess is const and that's why I've not used it to illustrate the issue. Hope this works. Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

Oh! I see what you are doing. That's a really good approach.

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

This LGTM. Thanks for working on this!

@Josh-Cena Josh-Cena merged commit 7d8ee59 into mdn:main Jul 20, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Learn Learning area docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to replicate same result as documentation
2 participants