makeOutWord
Given an 'out' string length 4, such as '<<>>', and a word, return a new string where the word is in the middle of the out string, e.g. '<<word>>'.
Examples
makeOutWord('<<>>', 'Yay') → '<<Yay>>'
makeOutWord('<<>>', 'WooHoo') → '<<WooHoo>>'
makeOutWord('[[]]', 'word') → '[[word]]'
Starter code
function makeOutWord(out, word) {
}
Complexity of the optimal solution
Time O(n), space O(n). String concatenation and substring operations can take time proportional to the string lengths. The length of the new string is dependent on the length of the input 'word' (n). Therefore, both time and space complexity are O(n).