- Instantiate an array from the string
- Use Array#splice
- Stringify again using Array#join
The benefits of this approach are two-fold:
- Simple
- Unicode code point compliant
const pair = Array.from('USDGBP')pair.splice(3, 0, '/')console.log(pair.join(''))
The benefits of this approach are two-fold:
const pair = Array.from('USDGBP')pair.splice(3, 0, '/')console.log(pair.join(''))