tags | |
---|---|
|
On the surface, a cat detector is a just simple program:
- First it asks you for a cat:
let input = prompt('cat, please');
- Then it checks if you gave it a cat:
const isCat = input === 'cat';
- If did give it a cat, the detector is satisfied:
if (isCat) alert('thank you for the cat');
- Otherwise it keeps asking you for a cat until you give it one:
else { while (input !== 'cat') input = prompt('still not a cat. \n\ncat, please');
- When you're done out-stubborning a computer, the program ends:
alert('finally, a cat.'); }
But really, a cat detector is an excuse to draw a bunny.