Question 5
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
function connect(host = "localhost", port = 3306) {
"use strict";
return `${host}:${port}`;
}
console.log(connect());
- A It prints localhost:3306
- B It prints undefined:undefined
- C ReferenceError: host is not defined
- D SyntaxError: a function with default, rest or destructured parameters cannot contain a "use strict" directive Correct
Correct Answer: Option D
"Illegal 'use strict' directive in function with non-simple parameter list". Put "use strict" at the top of the file (or use a module, which is always strict).
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!