JS Built-ins
StrictModebeginner

Duplicate Parameters in Strict Mode

Duplicate Parameters in Strict Mode

Strict mode forbids duplicate parameter names in functions. function f(a, a) throws a SyntaxError in strict mode.

Challenge: Write testDuplicateParams() that:

  1. Uses eval to run a function with duplicate parameters in strict mode
  2. Wraps it in try/catch
  3. Returns true if an error is caught, false otherwise
πŸ’‘ Hints (2)
  • β€’ Use eval() to parse and execute the function with duplicate params in strict mode
  • β€’ Any error thrown means strict mode rejected it