Yearly Pay yearly and get 2 months free on every paid plan. See plans
Sign in Start free

Refactor advisor

Input
Code
function add(a, b) { return a + b; }
Sample output Made on 27 October 2026
function addNumbers(firstNumber: number, secondNumber: number): number {
  return firstNumber + secondNumber;
}
  • Added number parameter types to fix the implicit any parameters.
  • Restricted both operands to numbers, removing ambiguity between numeric addition and string concatenation.
  • Added an explicit number return type to document and enforce the function’s contract.
  • Renamed add, a, and b to addNumbers, firstNumber, and secondNumber for clearer intent.
Use this Refactor advisor The form opens filled with this sample's inputs; change anything.