Skip to content

Commit 1c12f47

Browse files
committed
Update str_replace.js
1 parent f415314 commit 1c12f47

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

functions/strings/str_replace.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@ function str_replace(search, replace, subject, count) {
3737
sa = Object.prototype.toString.call(s) === '[object Array]';
3838
s = [].concat(s);
3939

40-
if(typeof(search) == 'object' && typeof(replace) == 'string' ) {
41-
temp = replace; replace = new Array();
42-
for (i=0; i < search.length; i+=1) { replace[i] = temp; }
43-
// update vars
44-
temp = ''; r = [].concat(replace); ra = Object.prototype.toString.call(r) === '[object Array]';
40+
if(typeof(search) === 'object' && typeof(replace) === 'string' ) {
41+
temp = replace;
42+
replace = new Array();
43+
for (i=0; i < search.length; i+=1) {
44+
replace[i] = temp;
45+
}
46+
temp = '';
47+
r = [].concat(replace);
48+
ra = Object.prototype.toString.call(r) === '[object Array]';
4549
}
4650

4751
if (count) {

0 commit comments

Comments
 (0)