I need to replace 1 with a 0, and replace 0 with 1 in a string. I know how to replace one thing with another, but how can I replace two separately. See the attempt below.
const broken = str => {
return str.replace(/1/g, '0').replace(/0/g, '1');
}
This is an example:
input
011101
output
100010