Created
November 18, 2013 00:01
-
-
Save MauriceButler/7520065 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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