بدائل If (مثل Unless, Provided That, As Long As, In Case)

بدائل If (مثل Unless, Provided That, As Long As, In Case) — Bài Tập 1

/ 10

بدائل If (مثل Unless, Provided That, As Long As, In Case) — Bài Tập 1

Luyện tập ngữ pháp tiếng Anh chủ đề بدائل If (مثل Unless, Provided That, As Long As, In Case) qua 10 câu hỏi trắc nghiệm. Trả lời đúng ít nhất 70% để hoàn thành bài.

أدوات شرط أخرى: unless (إذا لم)، provided that، as long as (فقط إذا)، in case (كإجراء احترازي).

B2 · فوق المتوسط TOEIC 605–780 IELTS 5.5–6.5 الجمل الشرطية والعبارات
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.

سجّل دخولك لحفظ نتيجتك

يمكنك أداء هذا الاختبار دون تسجيل الدخول، لكن لن يتم حفظ نتيجتك. تسجيل الدخول لمتابعة تقدمك.

  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?

← العودة إلى الموضوع