codesandbox / codesandbox/codesandbox-client

Parsing issue giving wrong output on codesandbox console

Open
#6,387 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13.6k
Forks
2.4k
Avg merge
6d 19h
Merged PRs (30d)
2

Description

🐛 bug report

let array = [1, 5, 3, 5, 6, 8];
const checkFun = (num1, num2) => {
for (let i = 0; i < array.length; i++) {
if (array[i] === num1) array[i] = num2;
}
};
console.log("before", array);
//Expected - [1, 5, 3, 5, 6, 8]
//Output - [1, 10, 3, 10, 6, 8]
checkFun(5, 10);
console.log("after", array);

If I run the same code on the console of any browser , its giving me the correct output . The console of codesandbox is giving a different and not-expected output.

Contributor guide

Open the contributing guide

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

Start by reproducing the provided JavaScript snippet in the CodeSandbox console and compare its output with a browser console. Trace the console's parsing or execution entry point to determine where the observed output diverges; done means the same snippet produces the expected array without regressing related console behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.