Bird
0
0

Which of the following is the correct way to chain these transformations inside the pipe's transform method?

hard📝 component behavior Q8 of 15
Angular - Standalone Components
You want to create a standalone pipe that formats a date string to uppercase and then reverses it. Which of the following is the correct way to chain these transformations inside the pipe's transform method?
Areturn value.split('').reverse().join('').toUpperCase();
Breturn value.toUpperCase().split('').reverse().join('');
Creturn value.reverse().toUpperCase();
Dreturn value.toUpperCase().reverse().join('');
Step-by-Step Solution
Solution:
  1. Step 1: Understand string methods chaining

    To uppercase then reverse, first call toUpperCase(), then split to array, reverse array, and join back.
  2. Step 2: Evaluate options

    return value.toUpperCase().split('').reverse().join(''); correctly chains methods in order. return value.split('').reverse().join('').toUpperCase(); reverses before uppercase, C uses invalid reverse on string, D calls reverse on string directly.
  3. Final Answer:

    return value.toUpperCase().split('').reverse().join(''); -> Option B
  4. Quick Check:

    Uppercase then reverse = toUpperCase + split + reverse + join [OK]
Quick Trick: Strings need split before reverse, then join after [OK]
Common Mistakes:
  • Calling reverse directly on string
  • Reversing before uppercase
  • Missing join after reverse

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes