Given the string \'Hello ?, welcome to ?\' and the array [\'foo\', \'bar\'], how do I get the string \'Hello foo, welcome to bar\' in
\'Hello ?, welcome to ?\'
[\'foo\', \'bar\']
\'Hello foo, welcome to bar\'
let str = 'Hello ?, welcome to ?' let arr = ['foo', 'bar'] const fn = Array.prototype.shift.bind(arr) let result = str.replace(/\?/g, fn) console.log(result);