We want to rewrite the following code snippet using the conditional operator:
let name; if (test) { name = 10; } else { name = 20; }
Which notation is correct?
let name = (test)("Alice")("Bob");
let name = if test ? "Alice" : "Bob";
let name = test ? "Alice" : "Bob";
let name = test : "Alice" ? "Bob";
More Questions: JavaScript Essentials 1 – JSE1: Module 4 Test
Please login or Register to submit your answer