Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Calculator {
}

// Poor variable naming and lacks clarity
calc(x, y, z) {
calc(x, y, z) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

claude-suggest: can you replace all of the ==
with === in the
calc function?

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue is using loose equality (==) instead of strict equality (===) in the calc function. Here's a fix:

Suggested change
calc(x, y, z) {
calc(x, y, z) {
if (z === '+') return this.add(x, y);
if (z === '-') return this.subtract(x, y);
if (z === '*') return this.multiply(x, y);
if (z === '/') return this.divide(x, y);
if (z === '^') return this.power(x, y);
if (z === '!') return this.factorial(x);
}

if (z == '+') return this.add(x, y);
if (z == '-') return this.subtract(x, y);
if (z == '*') return this.multiply(x, y);
Expand All @@ -51,4 +51,4 @@ class Calculator {
}
}

module.exports = Calculator;
module.exports = Calculator;
Loading