turulomio / moneymoney

Personal accounting and financial system
5 stars 0 forks source link

Try to replace string format and its translation #303

Closed turulomio closed 11 months ago

turulomio commented 11 months ago

function formatString(string, params) { return string.replace(/{(\d+)}/g, (match, index) => { return typeof params[index] !== 'undefined' ? params[index] : match; }); } var name = "Alex"; var age = 30; var formattedMsg = formatString("Hi, {0}! You are {1} years old.", [name, age]); console.log(formattedMsg);