Problem
function processUserData(userId, options = {}) {
  "use strict";
  let processedData = `User ID: ${userId}\n`;

  if (options.includeEmail) {
    processedData += "Email: user@example.com\n";
  }

  if (options.includeAge) {
    processedData += "Age: 25\n";
  }

  if (options.verbose) {
    processedData += "Processing mode: Verbose\n";
  }

  return processedData;
}

const userData = processUserData(12345, { includeEmail: true, verbose: true });
Solution

From MDN - “The ‘use strict’ directive can only be applied to the body of functions with simple parameters. Using “use strict” in functions with rest, default, or destructured parameters is a syntax error.”

There are a few ways to fix this. We can move the "use strict" directive to the top of the file, or we can remove the default parameter from the function signature, but if we wanted to keep both the default parameter and the "use strict" directive, we can go old school and check if the options parameter is undefined and set it to an empty object.

function processUserData(userId, options) {
  "use strict";
  if (typeof options !== "object" || options === null) {
    options = {};
  }
  let processedData = `User ID: ${userId}\n`;

  if (options.includeEmail) {
    processedData += "Email: user@example.com\n";
  }

  if (options.includeAge) {
    processedData += "Age: 25\n";
  }

  if (options.verbose) {
    processedData += "Processing mode: Verbose\n";
  }

  return processedData;
}

const userData = processUserData(12345, { includeEmail: true, verbose: true });