for (var n = 0; n < 100; n++) { console.log(/2/.test(n) ? 'xxx' : /3/.test(n) ? 'yyy' : n); }
<script> for (var n = 0; 100 > n; n++) document.write(n + " -> " + ("" + n).replace(/\d*(2|3)\d*/, function(b, a) { return { 2: "xxx", 3: "yyy" }[a] }) + "<br>"); </script>
if (/2/.test(n) === true) { console.log('xxx'); } else if(/3/.test(n) === true) { console.log('yyy'); } else { console.log(i); }