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 1

/ 10

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

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 1

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

    A function `calculateDiscount(price, coupon)` needs to return 0 if `coupon` is null or invalid. What is the best way to implement this using a guard clause?

  2. 2

    What is the result of `const result = (10 > 5) ? 'Greater' : 'Smaller';`?

  3. 3

    In a language with optional chaining, if `data` is an array of objects, and you want to safely access the `name` property of the first element, which might not exist, how would you write it?

  4. 4

    To provide a default value for a date variable `eventDate` to today's date if it's null or undefined, which operator is most suitable?

  5. 5

    A function `fetchData(id)` should return an empty array immediately if `id` is negative. How would you implement this using a guard clause?

  6. 6

    Consider the code: `let status = (score > 90) ? 'Excellent' : 'Good';`. What is 'Excellent' if score is 95?

  7. 7

    You want to ensure a function parameter `name` always has a value, defaulting to 'Anonymous' if it's not provided or is an empty string. Which operator can help achieve this concisely?

  8. 8

    You are building a system that needs to apply different validation rules (e.g., `EmailValidator`, `PasswordValidator`, `AgeValidator`) based on the type of data being validated. Instead of using `if-else if` to select the validator, you store validator instances in a map where keys are data types and values are validator objects. What is this an example of?

  9. 9

    You are building a system that needs to retrieve environment variables. If an environment variable is not set, you want to use a default value. Which operator is ideal for this, especially if an empty string is a valid configuration?

  10. 10

    When is it generally preferable to use a `switch` statement over a long `if-else if` ladder?