In JavaScript, you can return the next number from an integer by simply adding `1` to the given number. Here's how you can do it:
Basic Function
function nextNumber(num) {
return num + 1;
}
console.log(nextNumber(5)); // Output: 6
console.log(nextNumber(-1)); // Output: 0
console.log(nextNumber(100)); // Output: 101
Arrow Function Version
const nextNumber = num => num + 1; console.log(nextNumber(10)); // Output: 11This works for all integers, whether positive, negative, or zero. Would you like a version that ensures the input is always a valid number?