Worksheet


Q3.Define a reusable,  portable function that gives you the sum of two numbers. You should be able to copy and paste the function definition and only the function definition into a different sketch and use it without creating errors.

Why can a function return result of an operation, such as a + b, directly without first creating a variable such as Sum?

For example:

function addNumber(a, b) {
  return a + b;
}

How does the value returned by the function get assigned to Sum in:

let Sum = addNumber(10, 3);