Write a function, addTag(s, tag) that takes a string, s, and another string, tag
ID: 3723670 • Letter: W
Question
Write a function, addTag(s, tag) that takes a string, s, and another string, tag, and returns a new string the surrounds the string s with an html style tag. An HTML tag consists of a left angle bracket, the tag, and the right angle bracket. HTML tags come in pairs and the second one has a "/" before the tag. Study the following examples to see how it should work: addTags("Hello", "pre") should return the string '<pre>Hello</pre>' addTags("Some more text", "bold") should return the string '<bold>Some more text</bold>'
Explanation / Answer
public String addTag(String s,String tag) {
String output = "<" + tag + ">" + s + "</" + tag +">";
return output;}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.