Skip to content

Instantly share code, notes, and snippets.

@MauriceButler
Created November 18, 2013 00:01
Show Gist options
  • Save MauriceButler/7520065 to your computer and use it in GitHub Desktop.
Save MauriceButler/7520065 to your computer and use it in GitHub Desktop.
var fs = require('fs'),
path = require('path'),
cancer = '.coffee',
body = './body',
totalCells,
cellsChecked;
function killCancerCell(cell) {
fs.unlinkSync(path.join(body, cell));
console.log('Removed a cancer cell');
}
fs.readdir(body, function (error, cells){
if(error){
return console.error('Its terminal.');
}
totalCells = cells.length;
for (cellsChecked = 0; cellsChecked < totalCells; cellsChecked++) {
if(cells[cellsChecked].indexOf(cancer, cells[cellsChecked].length - cancer.length) !== -1){
killCancerCell(cells[cellsChecked]);
}
}
return console.log('We cured cancer!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment