Skip to content

Incorrect return value when one of the inputs is null in a function that adds two numbers. The function should handle null values gracefully and return a meaningful result, or throw an error.

Notifications You must be signed in to change notification settings

Bug-Hunter-X/js-function-null-input-handler-kq62f

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

JavaScript Function Bug: Incorrect Null Handling

This repository demonstrates a common bug in JavaScript functions: incorrect handling of null or undefined inputs. The foo function is intended to add two numbers, but it returns 0 when either input is null. This behavior might be unexpected and could lead to incorrect results in applications.

The bug.js file contains the buggy code. The bugSolution.js file offers a corrected version that handles null values appropriately.

About

Incorrect return value when one of the inputs is null in a function that adds two numbers. The function should handle null values gracefully and return a meaningful result, or throw an error.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published