Below, you can find another hint for the Challenge.
You should only get here after reading, digesting, and applying the .
You probably discovered that you cannot put something like
inside fragment_2 to make it output the missing fragment_1 (because it contains quotes).
N.B. Using double quotes as string delimiters would work ():
But we consider that cheating (by using advanced features of JavaScript). And, besides, it is still not an acceptable solution because all statements appear on one long line.
By the way, did you notice that the character sequence var S = now appears three times in the program!
And you also discovered that using a second string variable will not work either, because in that case, you need to deal with three fragments (and another infinite regress lurks).
In both cases, the problem is that single quotes cannot appear as such inside a string literal that itself is delimited by single quotes.
Here is another idea for you try: Put both fragments inside that same string S, and use the program statements in fragment_2 to extract these parts separately. This can be done by using the string operation substr (see Expressions in JavaScript Basics for details), without the use of single quotes!
For string s, the expression s.substr(i, n) returns the substring of s consisting of n consecutive characters starting at index i (the first character is at index 0). For example, the program
outputs ():
Can you implement this idea?
Try your program in the machine, and see if you can extend it to a complete solution. (Do remember that all statements on a single line is not acceptable as a final solution, because this violates reasonable coding conventions. However, do ignore this requirement for the moment.)
It is your turn ...
If you tried this hint, or do not see how it helps, then you are ready for the .