Link to home
Start Free TrialLog in
Avatar of gudii9
gudii9Flag for United States of America

asked on

tag challenge

Hi,

I am trying below example

http://codingbat.com/prob/p147483


i put code as below
public String makeTags(String tag, String word) {
  return "<"+tag+">"+word+"<"+tag+">";
}

Open in new window


I got output as below
Expected      Run            
makeTags("i", "Yay") → "<i>Yay</i>"      "<i>Yay<i>"      X         
makeTags("i", "Hello") → "<i>Hello</i>"      "<i>Hello<i>"      X         
makeTags("cite", "Yay") → "<cite>Yay</cite>"      "<cite>Yay<cite>"      X         
makeTags("address", "here") → "<address>here</address>"      "<address>here<address>"      X         
makeTags("body", "Heart") → "<body>Heart</body>"      "<body>Heart<body>"      X         
makeTags("i", "i") → "<i>i</i>"      "<i>i<i>"      X         
makeTags("i", "") → "<i></i>"      "<i><i>"      X         
other tests


How do i improve and fix my code.
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gudii9

ASKER

public String makeTags(String tag, String word) {
  return "<"+tag+">"+word+"<"+tag+"/>";
}

Open in new window


I tried as above still test cases are failing. Please advise on what i am doing wrong.
Expected      Run            
makeTags("i", "Yay") → "<i>Yay</i>"      "<i>Yay<i/>"      X         
makeTags("i", "Hello") → "<i>Hello</i>"      "<i>Hello<i/>"      X         
makeTags("cite", "Yay") → "<cite>Yay</cite>"      "<cite>Yay<cite/>"      X         
makeTags("address", "here") → "<address>here</address>"      "<address>here<address/>"      X         
makeTags("body", "Heart") → "<body>Heart</body>"      "<body>Heart<body/>"      X         
makeTags("i", "i") → "<i>i</i>"      "<i>i<i/>"      X         
makeTags("i", "") → "<i></i>"      "<i><i/>"      X         
other tests
X
Avatar of gudii9

ASKER

public String makeTags(String tag, String word) {
  return "<"+tag+">"+word+"</"+tag+">";
}

Open in new window


above worked fine