Search posts, tags, users, and pages
Yogesh Chavan
Full Stack Developer | Freelancer | JavaScript | React | Nodejs. https://yogeshchavan.dev/. Book 1:1 @ hiretheauthor.com/myogeshchavan97
Today we will see a frequently asked Javascript interview question. The question goes like this: Implement a product method that will return the product of two numbers when invoked using any of the following two ways product(4, 5) product(4)(5) T...
Sasikumar Reddy Chevvu
Front End Developer
Great Share ๐, Thanks Yogesh
Glad to hear that. Thank you Sasikumar Reddy Chevvu๐
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; }
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; }
Sasikumar Reddy Chevvu
Front End Developer
Great Share ๐, Thanks Yogesh