gudii9
asked on
tag challenge
Hi,
I am trying below example
http://codingbat.com/prob/p147483
i put code as below
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.
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+">";
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
public String makeTags(String tag, String word) {
return "<"+tag+">"+word+"</"+tag+">";
}
above worked fine
ASKER
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