Following are the test cases
Test cases | Result | Status |
---|---|---|
makeOutWord(<<>>,Yay) | <<Yay>> | OK |
makeOutWord([[]],Word) | [[Word]] | OK |
makeOutWord([((JAVA))] | ((JAVA)) | OK |
Java solution
package test;
public class Program17 {
public static void main(String[] args) {
Program17.makeOutWord("<<>>", "Yay");
Program17.makeOutWord("<<>>", "WooHoo");
Program17.makeOutWord("[[]]", "word");
}
public static String makeOutWord(String out, String word) {
return out.substring(0, 2) + word + out.substring(2,4);
}
}
Javascript solution
const makeOutWord = (out, word) => {
return out.substr(0, 2) + word + out.substr(2, 4);
}
console.log(makeOutWord("<<>>", "Yay")); //<>
console.log(makeOutWord("<<>>", "WooHoo")); //[[Word]]
console.log(makeOutWord("[[]]", "word")); //((JAVA))