Skip to content

dev-alihasan/JavaScript-problems

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

JavaScript-problems

1. Problem: Return the Sum of Two Numbers

Write a function addNumbers that takes two numbers as input and returns their sum.
Input: Two numbers, num1 and num2.

Output:
The sum of num1 and num2.

Constraints:
Both num1 and num2 are integers or floating-point numbers.

Example:

addNumbers(5, 7)  12
addNumbers(-3, 10)  7
addNumbers(2.5, 3.5)  6

Note

  1. Ensure that the function handles invalid inputs appropriately.
  2. If either input is not a number, return the message: "both inputs should be numbers.

2. Problem: Return Next Number from the Integer Passed

Problem Description:
Write a JavaScript function called getNextNumber that takes an integer as input and returns the next integer.

getNextNumber(5); // Output: 6
getNextNumber(-8); // Output: -7
getNextNumber(0); // Output: 1

Note

  1. The input integer can be positive, negative, or zero.
  2. The input integer will be within the range of a 32-bit signed integer.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published