Bird
0
0

You want to create a custom pipe truncate that shortens a string to a given length passed as a parameter. Which of these pipe transform method signatures correctly supports a parameter for length?

hard📝 Application Q15 of 15
Angular - Pipes
You want to create a custom pipe truncate that shortens a string to a given length passed as a parameter. Which of these pipe transform method signatures correctly supports a parameter for length?
Atransform(value: string, length: number): string
Btransform(value: string): string
Ctransform(length: number, value: string): string
Dtransform(): string
Step-by-Step Solution
Solution:
  1. Step 1: Recall pipe transform method signature

    The first argument is the value, followed by optional parameters.
  2. Step 2: Check parameter order and types

    transform(value: string, length: number): string correctly has value first, then length parameter.
  3. Final Answer:

    transform(value: string, length: number): string -> Option A
  4. Quick Check:

    Pipe transform(value, params...) signature [OK]
Quick Trick: First argument is value, next are parameters in transform() [OK]
Common Mistakes:
  • Swapping parameter order
  • Omitting parameters
  • Using no parameters at all

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes