Các Cách Thay Thế 'If' Trong Câu Điều Kiện

Các Cách Thay Thế 'If' Trong Câu Điều Kiện — Bài Tập 4

/ 10

Các Cách Thay Thế 'If' Trong Câu Điều Kiện — Bài Tập 4

Luyện tập ngữ pháp tiếng Anh chủ đề Các Cách Thay Thế 'If' Trong Câu Điều Kiện qua 10 câu hỏi trắc nghiệm. Trả lời đúng ít nhất 70% để hoàn thành bài.

Tìm hiểu các liên từ điều kiện khác có thể thay thế 'if' như 'unless' (nếu không), 'provided that', 'as long as' (chỉ khi), 'in case' (đề phòng), giúp bạn đa dạng hóa cấu trúc câu.

B2 · Trung cấp nâng cao TOEIC 605–780 IELTS 5,5–6,5 Mệnh Đề & Câu Điều Kiện
10 câu hỏi Điểm qua: 70% Bài 4

Hướng dẫn làm bài

  • Đọc kỹ từng câu hỏi và chọn đáp án đúng nhất.
  • Bài thi không giới hạn thời gian — bạn có thể làm theo tốc độ của mình.
  • Nhấn Nộp bài khi đã hoàn thành để xem kết quả và giải thích chi tiết.

Đăng nhập để lưu kết quả

Bạn có thể làm bài kiểm tra mà không cần đăng nhập, nhưng kết quả sẽ không được lưu. Đăng nhập để theo dõi tiến trình của bạn.

  1. 1

    You want to add an item to an array `cart` only if `item` is not null. Which short-circuiting expression is suitable?

  2. 2

    You want to submit a form only if `isValidForm` is true. Which short-circuiting expression is suitable?

  3. 3

    You are building a system that needs to handle different types of user input (e.g., keyboard events, mouse clicks, touch gestures). Instead of using `if-else if` to check the input type and call the specific handler, you define a common `IInputHandler` interface and have specific handler classes implement it. What is this an application of?

  4. 4

    You want to display a loading spinner only if `isLoading` is true. Which short-circuiting expression is suitable?

  5. 5

    Which of the following is a common use case for a `switch` statement with string values?

  6. 6

    A system needs to support various sorting algorithms (e.g., QuickSort, MergeSort, BubbleSort). The choice of algorithm depends on factors like data size and expected distribution. Which design pattern would allow you to dynamically select and apply a sorting algorithm without modifying the client code that uses it, replacing a large `if-else if` structure?

  7. 7

    To map HTTP status codes to descriptive messages (e.g., 200 to 'OK', 404 to 'Not Found'), which data structure is most efficient for replacing a large `switch` statement?

  8. 8

    In a language with optional chaining, if `user` is an object, but `user.profile` is `undefined`, what will `user?.profile?.getAvatarUrl()` evaluate to?

  9. 9

    You are refactoring a system where a complex `if-else if` structure is used to manage different stages of a document approval process (e.g., 'Draft', 'Review', 'Approved', 'Rejected'). The available actions (e.g., `submit()`, `approve()`, `reject()`) and their behavior change significantly depending on the current stage. Which design pattern is best suited to model this workflow and eliminate conditional logic based on state?

  10. 10

    A function `validateUser(user)` needs to ensure `user` is an object and has a `name` property. If not, it should return `false` immediately. How would you use guard clauses for this?