Strings: making HTML tags

From Computer Science Wiki
Revision as of 11:39, 15 March 2016 by Bmackenty (talk | contribs) (Created page with "This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is a problem set. Some of these are easy, others are far more difficult. The purpose of these problems sets are to HELP YOU THINK THROUGH problems. The solution is at the bottom of this page, but please don't look at it until you have tried (and failed) at least three or four times.

The problem

The web is built with HTML strings like "Yay" which draws Yay as italic text. In this example, the "i" tag makes and which surround the word "Yay". Given tag and word strings, create the HTML string with tags around the word, e.g. "Yay".

make_tags('i', 'Yay') → 'Yay' make_tags('i', 'Hello') → 'Hello' make_tags('cite', 'Yay') → 'Yay'