jaredhanson / jaredhanson/connect-flash

Wrong example checking for message

Open
#16 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
1.2k
Forks
173
PR merge metrics
No merged PRs in 30d

Description

The examples show that this `if (message) {` is the proper way to check if a message is there, actually this will be true every time, even if no message is set. It seems to work with:

``` js
if (message.length !== 0) {
```

I am not sure, but it seems that message, when empty is an empty object (`{}`) so checking for it will be true in any case.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the JavaScript examples that use `if (message) {` and verify how an empty message is represented. Confirm the condition behaves incorrectly for an empty object, then update the example so it checks for an actually present message and verify the corrected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.