Alternatif Pengganti 'If' (Unless, Provided That, As Long As, In Case)

Alternatif Pengganti 'If' (Unless, Provided That, As Long As, In Case) — Exercise 5

/ 10

Alternatif Pengganti 'If' (Unless, Provided That, As Long As, In Case) — Exercise 5

Practice English grammar topic Alternatif Pengganti 'If' (Unless, Provided That, As Long As, In Case) with 10 multiple-choice questions. Answer at least 70% correctly to complete the test.

Konjungsi pengkondisian lainnya: unless (jika tidak), provided that, as long as (hanya jika), in case (sebagai pencegahan).

B2 · Upper Intermediate (Menengah Atas) TOEIC 605–780 IELTS 5,5–6,5 Klausa & Kalimat Pengandaian (Conditionals)
10 questions Skor kelulusan: 70% Test 5

How to take the test

  • Read each question carefully and select the best answer.
  • The test is not timed — you can complete it at your own pace.
  • Click Kumpulkan Tes when finished to see your score and detailed explanations.

Masuk untuk menyimpan hasilmu

Kamu bisa mengerjakan tes ini tanpa masuk, tetapi hasilnya tidak akan tersimpan. Masuk untuk melacak progresmu.

  1. 1

    You are refactoring a system where a complex `if-else if` structure is used to determine the behavior of an object based on its components (e.g., a `Graphic` object can be a `Circle`, `Square`, or a `Group` of graphics). Which design pattern would allow you to treat individual objects and compositions of objects uniformly, thus avoiding conditional logic for handling different types?

  2. 2

    You are building a system that needs to map UI component names to their corresponding React/Vue/Angular components (e.g., 'Button' to `<ButtonComponent>`, 'Input' to `<InputComponent>`). Which data structure is most efficient for replacing a large `if-else if` or `switch` statement for dynamic component rendering?

  3. 3

    When refactoring a series of `if-else if` statements that check for different types of objects and perform type-specific actions, which design principle or pattern is often a superior alternative?

  4. 4

    Consider a scenario where you need to access a property of an object, but the object itself or an intermediate property might be null or undefined. Which operator provides a safe way to access nested properties without explicit null checks?

  5. 5

    What is the value of `discount` in `const discount = (isPremium) ? 0.15 : 0.05;` if `isPremium` is `true`?

  6. 6

    In many languages, what is the primary keyword used to define a block of code that executes based on the value of an expression in a switch statement?

  7. 7

    A payment processing system needs to support various payment methods (e.g., Credit Card, PayPal, Bank Transfer). Each method has a distinct set of steps for authorization and capture. Which design pattern would best allow you to add new payment methods without modifying the core payment processing logic, replacing a large `if-else if` structure?

  8. 8

    Which of the following is a valid way to use a `switch` statement with an `enum` type?

  9. 9

    In a `switch` statement, if a `case` block does not have a `break` statement, what happens?

  10. 10

    If `user.isAdmin` is false, what is the outcome of `user.isAdmin && showAdminPanel();`?