xGrimReaperx 0 Newbie Poster

Hello I have two array that I want to use like String.Format

Array 1:

{ "{0}", "-", "{1}" }

Array 2:

{ "1", "2" }

I want to use values from Array 2 to replace all {0}, {1} in Array 1 etc.

so what I have tried:

var i = array2.length,
var result = $.map(array1, function (v){


       stringFormat = [];

        while (i--) {
              v = v.replace(/{(\d+)}/g, values[i]);
              stringFormat.push(v);
         }
        return stringFormat;
});

But it currently freezes the page

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.