© 2026 LinearBytes Inc.
Search posts, tags, users, and pages
Chety
Solving everyday problem by code
You can check your second parameter as below without 0 trap.
0
if (b != undefined) { // if b provided return a * b; }
Yogesh Chavan
Full Stack Developer | Freelancer | JavaScript | React | Nodejs. https://yogeshchavan.dev/. Book 1:1 @ hiretheauthor.com/myogeshchavan97
Chety Thanks, that will work but it's always good to use strict comparison inside if condition to avoid type coercion like this:
if (b !== undefined) { // if b provided return a * b; }