code-problems/problems/string-format/Readme.md at master · smalldatatech/code-problems · GitHub
Skip to content

Latest commit

 

History

History
12 lines (8 loc) · 306 Bytes

File metadata and controls

12 lines (8 loc) · 306 Bytes

String Format

Create a string formatting function that accepts an input string and a number of arguments to replace positions in the input string.

Example

f('Hello {0} {1}', 'Mr.', 'X') // => 'Hello Mr. X'
f('{1}_{0}', '{1}', '{0}')     // => '{0}_{1}'

By Riga.