Question 2
Back to Exercise
JavaScript refuses to run the code below. Which statement correctly describes the problem?
const greeter = {
greet() => "Hello",
};
console.log(greeter.greet());
- A It prints Hello
- B TypeError: greet is not a function
- C It prints undefined
- D SyntaxError: write either greet() { return "Hello"; } or greet: () => "Hello", not a mix of both Correct
Correct Answer: Option D
Method shorthand needs a body in braces; an arrow function must be the value of a key: greet: () => "Hello".
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!