fork download
  1. const oddNumbers = /[a-z]*\s*[0-9]*[1,3,5,7,9]\s*[a-z]*/g
  2.  
  3. function omitOdd(string){
  4. if (oddNumbers.test(string)){
  5. let token = /[0-9]+[1,3,5,7,9]|\s[1,3,5,7,9]\s/g
  6. let res = string.replace(token," BEEP ")
  7. console.log(res)
  8. }else{
  9. console.log("He is safe")
  10. }
  11. }
  12.  
  13. omitOdd("He has 203 cars, 10 are green, 11 are black and 3 are yellow")
Success #stdin #stdout 0.03s 16480KB
stdin
Standard input is empty
stdout
He has  BEEP  cars, 10 are green,  BEEP  are black and BEEP are yellow