Ok I’m designing a facoring function that will take a string-number
containing numbers from 0-7 (octal radix=8) and
Every time that the function detects exactly 3 numbers of any one number, then it’ll remove all three.
So if the function accpeted an argument of, say—”034202210223″
the function will first sort the numbers to “000122222334”
then remove all instances of 3-in-a-row and thus returning removeing
the numbers in red “[color=red]000[color=red]222
an argument of “034202210223”.
[size=+1]Here’s my function as of now:
[code]
function factormove(){
var string_number=arguments[0].split(“”).sort().join(“”)
string_number=string_number.replace(/000/g,”a”).replace(/111/g,”a”)
.replace(/222/g,”a”).replace(/333/g,”a”).replace(/444/g,”a”)
.replace(/555/g,”a”).replace(/666/g,”a”).replace(/777/g,”a”)
.replace(/a/g,””);
return string_number
}
//all the replaces are supposed to be on one line
So it there a way to put all them replaces into one statement?