How to make it so that when comparing two arrays, when the first identical element is found, the search ends and this element is recorded in the 3rd array. In the example, the array is obtained with: ((AB)) + C, but it is necessary that the following result be output: the array with: (AB) + C array a :() in the array and the remaining elements!
var a = "ABC()-()+"; var b = "(AB)+C"; var c = []; document.write("ΠΌΠ°ΡΡΠΈΠ² Π°: "); document.write(a); document.write("<br>"); document.write("ΠΌΠ°ΡΡΠΈΠ² b: "); document.write(b); for (var i = 0; i < b.length; i++) { for (var j = 0; j < a.length; j++) { if (b[i] == a[j]) { c.push(b[i]); } } } document.write("<br>"); document.write("ΠΌΠ°ΡΡΠΈΠ² c: "); document.write(c); document.write("<br>"); document.write("ΠΌΠ°ΡΡΠΈΠ² a: "); document.write(a);