CoddityTeam / movaicode

Concours mensuel du Pire Développeur de France
122 stars 10 forks source link

ಠ_ಠ replace hell #262

Open lhoang opened 1 year ago

lhoang commented 1 year ago
function viderLeBacALegumes(bac) {
  ಠ_ಠ = (""+ bac).replace(/IPA/g, '')
    .replace(/REDBULL/g, '')
    .replace(/8\.6/g, '')
    .replace(/,,+/g,',')

  if (ಠ_ಠ[0] == ',') ಠ_ಠ = ಠ_ಠ.substr(1)
  if (ಠ_ಠ[ಠ_ಠ.length-1] == ',') ಠ_ಠ = ಠ_ಠ.substr(0,ಠ_ಠ.length-2)

  ಠ_ಠ= eval("['" + ಠ_ಠ.replace(/,/g, "','") + "']")

  return ಠ_ಠ
}

let bac = ["IPA","FENOUIL","TOMATE","REDBULL","8.6","SALADE","POIREAUX"]

console.log(viderLeBacALegumes(bac))