Solution Review: Tagged Template
Explore how to create a tagged template function that transforms embedded expressions to uppercase and eliminates leading whitespace using regex. Understand the use of spread operators, map, join, and trim methods to manipulate template literals effectively in JavaScript.
We'll cover the following...
We'll cover the following...
Solution
We will review the following solution step-by-step.
Explanation
There are two main functionalities that tag stripMargin has to implement to get the desired output.
- Convert all expressions to upper case
- Remove all leading spaces and indentations on the new lines
So, let’s start with the first one.
Converting expressions
In the function definition at line 3, we are taking two parameters:
textsexpressions
expressions
The ...