In Javascript
function doomPercentage(s) { let infected = 0; let total = 0; if(!s.includes('1') || !s.includes('0')){ return 0; } s.split('X').forEach(continent => { if(continent.includes('1')){ continent = continent.replace(/0/gi, '1'); infected += continent.length; } total += continent.length }); return 100*infected/total; };
`
nice function name :D
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In Javascript
`
nice function name :D