Functions

Return vs Log

Return vs Log

A function can log one value and return a different value. The log is for someone reading the console. The return value is what the caller receives.

Read this code:

js
function showInvoiceTotal(total) {
  console.log(total * 2);
  return total;
}

const result = showInvoiceTotal(12);

Your task: Predict the value stored in result and the value written to the console.

Prerequisites

  • variables
  • operators
  • functions

Tests

  • predictedReturn matches the value returned to the caller
  • predictedLog matches the value printed inside the function
  • both predictions are numbers
Loading...
Console

Run code to see output.

Previous1 / 27Next